Commit Graph
1047 Commits
Author SHA1 Message Date
64b5a59410 fix: schema cache loading before the in-db config (#3670)
Fixes #3660. Load the config after getting the pg version but before loading the schema.

The regression happened on f09655b.

Also remove schema cache load wrapper and separate db queries in different functions.

Co-authored-by: Laurence Isla <lau.isla.c@gmail.com>
2024-08-01 17:41:07 +02:00
Wolfgang Walther 53593824a8 fix: Embed One-to-One relationship with different column order properly 2024-07-13 22:27:04 +02:00
Salim BandWolfgang Walther 13868983af fix: update OpenAPI externalDocs URL
fixes https://github.com/PostgREST/postgrest/issues/3091
2024-07-13 17:11:06 +02:00
steve-chavez f09655b7a6 fix: schema cache retrying without backoff
Fixes https://github.com/PostgREST/postgrest/issues/3523.

Now if there's a failure when obtaining the pg version OR schema cache,
we do the same retrying process. This way we don't add two retries.

Refactors and renames the "connectionWorker" to "schemaCacheLoader".
This makes more sense since what we really want is the schema cache,
the version is the pre-requisite for ensuring our
schema cache queries work.

Additionally, we no longer log ` Attempting to connect to the database...`
at startup unnecessarily. This is only logged whenever there's a retry attempt.
2024-07-10 21:11:20 -05:00
Laurence IslaandWolfgang Walther 8f8dbd3425 fix: nested empty embeds no longer return empty values and are correctly omitted 2024-07-09 09:09:22 +02:00
Laurence Isla 9c165e3edb fix: log connection pool events on log-level="debug" instead of "info" 2024-05-24 17:19:31 -05:00
Laurence Isla c8612f1df1 test: use only the first line in the logs to check the server version 2024-05-24 17:19:31 -05:00
Taimoor ZaeemandSteve Chavez 8cbcf9867b feat: add config db-hoisted-tx-settings to allow only hoisted function settings 2024-05-21 19:50:03 -05:00
Taimoor ZaeemandSteve Chavez a1582a6136 test: clean test_role_settings in io-tests 2024-05-21 19:50:03 -05:00
Taimoor ZaeemandSteve Chavez 5cc32c7f87 fix: fix incorrect 413 error on pg 54* errors 2024-05-20 18:59:33 -05:00
steve-chavez 7e61c9deb0 feat: force read-write for listener connection 2024-05-19 23:14:19 -05:00
steve-chavez 3cf565614d fix: listener retries with exponential backoff
Also corrects the admin ready response which now considers the listener
state.
2024-05-19 20:48:59 -05:00
steve-chavez bfa4e1bedb test: isolate pg_terminate_backend to appname
The pg_terminate_backend done in the io test:

`test_fail_with_automatic_recovery_disabled_and_terminated_using_query`

Can affect other connections.
2024-05-19 19:58:27 -05:00
steve-chavez ae91fd89b3 test: assert empty response text on 204 2024-05-19 13:44:23 -05:00
steve-chavez d25df459ea feat: add metric label for scache load
localhost:3001/metrics now includes:

pgrst_schema_cache_loads_total{status="FAIL"} 352.0
pgrst_schema_cache_loads_total{status="SUCCESS"} 3.0

This allows testing the failure case on:

https://github.com/PostgREST/postgrest/issues/3424#issuecomment-2104904910
2024-05-14 17:57:21 -05:00
Wolfgang WaltherandWolfgang Walther 71885bdba6 test: Avoid freeport() collisions in io tests
It's very unlikely, but it can (and did) happen that both the server and
admin ports have the same number returned from freeport(). This then
leads to a situation where PostgREST will accept the same port in both
cases, because the host "localhost" will allow binding to ipv4 or ipv6
respectively. This will make the IO tests fail.

This change makes sure that the admin port will never be the same as the
server port and thus avoids this problem.
2024-05-12 11:45:06 +02:00
Wolfgang WaltherandWolfgang Walther 8392357863 test: Fix internal_schema_cache_sleep after 747c78f6
The $subject commit broke internal_schema_cache_sleep for other tests.
This reverts the order change, but keeps the scaling by x1000 to ms and
thus changes other users of this setting to the new scale.
2024-05-12 11:44:43 +02:00
Wolfgang Walther 1fa35cb3b8 test: Fix coverage & style check from c4295b3d 2024-05-09 18:50:00 +02:00
Wolfgang Walther 01a56db7d8 test: Make unicode insert test work in parallel mode
Changing the PK here will avoid duplicate conflicts with another test.

References #1799
2024-05-09 18:05:44 +02:00
Wolfgang Walther 577a7c7598 test: Move limited delete/update tests into separate spec file
This potentially allows to run the remaining tests in those files in
parallel mode.

References #1799
2024-05-09 18:05:44 +02:00
Wolfgang Walther c4295b3d63 test: Make PgSafeUpdateSpec parallel-ready 2024-05-09 18:05:44 +02:00
Wolfgang Walther aa94e436fa test: Missing space 2024-05-09 18:05:44 +02:00
Wolfgang Walther cf7a789e9e test: Improve failing test output for requestMutation 2024-05-09 18:05:44 +02:00
Wolfgang Walther a7ed5db78a test: Sort test suites in spec/Main.hs 2024-05-09 18:05:44 +02:00
Wolfgang WaltherandWolfgang Walther 747c78f6f4 test: Prevent test_admin_ready_includes_schema_cache_state from timing out
By increasing the delays in this test by factor 400x, postgrest will not
swamp pg with connection retries after the failed schema cache anymore.

This would happen because there is no backoff included after fatal
errors. Once it does, the io tests hang indefinitely in CI.
2024-05-09 13:36:03 +02:00
Wolfgang WaltherandWolfgang Walther e96e16fa27 test: Reset statement timeout after each test
The statement timeout needs to be cleaned up after each test that
modifies it instead of before the test. Otherwise the changed timeout
leaks into other tests.
2024-05-09 13:36:03 +02:00
steve-chavez 0060abeb01 feat: /live and /ready respond with 500 on failure
503 is still used by /ready to indicate a transient state
that can be recovered from.
2024-05-08 17:19:48 -05:00
Taimoor ZaeemandSteve Chavez 21bc48ad9a fix: fix wrong 503 Service Unavailable on pg error 53400 2024-05-06 07:54:11 -05:00
steve-chavez d9a51f23ce test: sanity tests for primary and replica
* new --replica option to `postgrest-with-postgresql-*`
* new command `postgrest-test-replica`
* new sanity tests on test_replica.py
* add postgrest-test-replica to postgrest-check and postgrest-coverage
2024-04-30 18:35:40 -05:00
steve-chavez cdb877135b test: flush stdout so readline doesn't hang 2024-04-30 13:52:51 -05:00
Laurence IslaandGitHub 69bbce5b32 feat: improve PGRST121 error message
* Clarify the message field
* Show failed MESSAGE or DETAIL in the the PGRST121 error's details field
* Show the correct JSON format in the hint field
2024-04-24 13:33:10 -05:00
steve-chavez 357400b2b8 feat: schema cache metrics 2024-04-23 19:08:37 -05:00
steve-chavez 653c7955b2 feat: connection pool metrics in admin server 2024-04-23 19:08:37 -05:00
steve-chavez 3e615bd0d9 feat: add log-level=debug 2024-04-22 21:36:29 -05:00
Taimoor ZaeemandSteve Chavez 88abf600c4 fix: fix wrong http status on pg error 42P17 infinite recursion 2024-04-22 13:40:07 -05:00
Wolfgang Walther 87a463f857 test: fix broken io tests after last commit
Forgot to update the snapshots.
2024-04-20 16:03:53 +02:00
Wolfgang Walther ed407350ad fix: hoist function settings with memory units properly
f9ee1f7e introduced the hoisting of function settings as transaction-scoped
settings. However, this currently doesn't work with memory units, which are
case-sensitive according to the docs [1]. This removes the lowercasing of
values to make them work.

This is not added to the CHANGELOG, because this feature was not released, yet.

[1]: https://www.postgresql.org/docs/current/config-setting.html#CONFIG-SETTING-NAMES-VALUES
2024-04-20 13:58:04 +02:00
Laurence IslaandSteve Chavez 0d13b842a6 fix: OpenAPI now tags a FK correctly on O2O relationships 2024-04-18 17:08:14 -05:00
steve-chavez 1bf0c54dd6 feat: log connection pool events on log-level=info 2024-04-15 18:31:51 -05:00
Steve ChavezandGitHub 9d1dc783bf test: use postgrest.read_stdout in io tests (#3412)
It's easier to maintain this way in case there are new log lines.
2024-04-15 13:51:23 -05:00
steve-chavez 69c6ce9c38 refactor: use LogLevel in Logger
* remove Logger dependency on Auth.
2024-04-14 20:10:01 -05:00
Taimoor ZaeemandSteve Chavez 973201a8d3 fix: remove rejected mediatype application/vnd.pgrst.object+json from response 2024-04-13 16:07:38 -05:00
steve-chavez fbc4d565ca refactor: move debounce from AppState to Logger
Will allow to capture accurate timeout metrics.
2024-04-12 14:29:39 -05:00
steve-chavez 2de32fc108 refactor: observation handler to AppConfig
With this:

- Is no longer necessary to pass observer as an argument
  to every function that needs observations.
- We can invoke the observer on every function that uses AppConfig.
  However it'd be better to just call the observer in the upper modules
  (like on App.hs).
2024-04-12 14:29:39 -05:00
Laurence IslaandGitHub 460259548d perf: fix space leaks by downgrading fuzzyset to v0.2.4 2024-04-11 14:13:20 -05:00
steve-chavez 3d55f77bae Revert "fix: slow responses on schema cache reload"
This reverts commit 727ef465c1.

Also documents requests waiting for the schema cache.
2024-04-02 23:15:09 -05:00
steve-chavez 2543b8d724 fix: clarify PGRST204 error message 2024-04-01 19:03:14 -05:00
Laurence Isla 378c11104b test: fix some in-db config values
To correctly test in-db override of config file values, the former must be different from the latter.
2024-03-27 15:59:35 -05:00
Laurence Isla 428a6fef63 fix: in-db config values not loading for pgrst.server_trace_header and pgrst.server_cors_allowed_origins 2024-03-27 15:59:35 -05:00
steve-chavez 941ea0f929 test: notify do nothing 2024-03-19 13:22:51 +03:30