fix(storage): use dynamic schema_getter in PostgreSQLFileStorage for multi-tenant#440
Merged
nicoloboschi merged 1 commit intovectorize-io:mainfrom Feb 25, 2026
Conversation
…multi-tenant PostgreSQLFileStorage was initialized once at startup with a static schema value. Since get_current_schema() returns the default schema at init time, multi-tenant requests always queried the wrong schema, causing "relation file_storage does not exist" errors. Replace static schema with schema_getter callable (same pattern used by BrokerTaskBackend since vectorize-io#208) so the schema is resolved dynamically per-request via contextvars.
nicoloboschi
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PostgreSQLFileStoragewas initialized once at startup with a staticschemavalue fromget_current_schema(). Since the context variable has no tenant set at init time, it always resolved to the default schema (public), causing "relation file_storage does not exist" errors for multi-tenant requests.schemawithschema_gettercallable — the same pattern already used byBrokerTaskBackendsince fix: multi-tenant schema context for worker task execution #208._schemaattribute becomes a@propertythat resolves dynamically per-request viacontextvars, so each tenant hits the correct schema.Details
This is the same class of bug fixed in:
83f44c4b— "fix: multi-tenant schema context for worker task execution (fix: multi-tenant schema context for worker task execution #208)" (BrokerTaskBackend)b180b3ad— "Fix bank config API for multi-tenant schema isolation (Fix bank config API for multi-tenant schema isolation #417)" (ConfigResolver)Backward compatible: the static
schemaparameter is preserved as a fallback for single-tenant deployments and tests.Test plan
test_file_retain.pyandtest_file_storage_s3.pytests pass (16/16)ruff check+ruff format)