From be2006f9928e31b50f587d2b3b93feda8b2ef9b9 Mon Sep 17 00:00:00 2001 From: Zsolt Parragi Date: Tue, 10 Feb 2026 20:46:27 +0000 Subject: [PATCH 1/2] Pin DSA buffer Without this we create-attach-detach, and it gets destroyed after the first connection, making the HTTP cache unusable. This makes sure that the area remains there even when there's no active reference to it. --- src/dshash_wrapper.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dshash_wrapper.hpp b/src/dshash_wrapper.hpp index 81dd70c..cbc248c 100644 --- a/src/dshash_wrapper.hpp +++ b/src/dshash_wrapper.hpp @@ -143,6 +143,7 @@ class dshash { if (state->area_handle == DSA_HANDLE_INVALID) { area = dsa_create(state->tranche_id); + dsa_pin(area); dsa_pin_mapping(area); dshash_parameters params = make_parameters(state->tranche_id); From d2f33289a7d9f2ed71d05d57cfad6d16747039e9 Mon Sep 17 00:00:00 2001 From: Zsolt Parragi Date: Tue, 10 Feb 2026 20:47:19 +0000 Subject: [PATCH 2/2] Detach HTTP cache manually on validator exit Otherwise the destructor tries to do this during library unloading time, but at that time shmem_exit already completed and we spam the error log with allocator errors. --- src/pg_oidc_validator.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pg_oidc_validator.cpp b/src/pg_oidc_validator.cpp index e56fec0..9fcf14c 100644 --- a/src/pg_oidc_validator.cpp +++ b/src/pg_oidc_validator.cpp @@ -19,10 +19,12 @@ extern "C" { PG_MODULE_MAGIC; } +void validator_shutdown(ValidatorModuleState*); bool validate_token(const ValidatorModuleState* state, const char* token, const char* role, ValidatorModuleResult* result); -static const OAuthValidatorCallbacks validator_callbacks = {PG_OAUTH_VALIDATOR_MAGIC, nullptr, nullptr, validate_token}; +static const OAuthValidatorCallbacks validator_callbacks = {PG_OAUTH_VALIDATOR_MAGIC, nullptr, validator_shutdown, + validate_token}; extern "C" { const OAuthValidatorCallbacks* _PG_oauth_validator_module_init(void) { return &validator_callbacks; } @@ -142,3 +144,8 @@ bool validate_token(const ValidatorModuleState* state, const char* token, const elog(WARNING, "OAuth validation failed with unknown internal error"); return false; } + +void validator_shutdown(ValidatorModuleState*) { + // Detach cache manually, otherwise the destructor will try to do it after shmem_exit already completed + pg::http_cache::get_instance().detach(); +}