Skip to content

fix(storage): use dynamic schema_getter in PostgreSQLFileStorage for multi-tenant#440

Merged
nicoloboschi merged 1 commit intovectorize-io:mainfrom
Andreymi:fix/file-storage-schema-getter
Feb 25, 2026
Merged

fix(storage): use dynamic schema_getter in PostgreSQLFileStorage for multi-tenant#440
nicoloboschi merged 1 commit intovectorize-io:mainfrom
Andreymi:fix/file-storage-schema-getter

Conversation

@Andreymi
Copy link
Contributor

Summary

  • PostgreSQLFileStorage was initialized once at startup with a static schema value from get_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.
  • Replace static schema with schema_getter callable — the same pattern already used by BrokerTaskBackend since fix: multi-tenant schema context for worker task execution #208.
  • The _schema attribute becomes a @property that resolves dynamically per-request via contextvars, so each tenant hits the correct schema.

Details

This is the same class of bug fixed in:

Backward compatible: the static schema parameter is preserved as a fallback for single-tenant deployments and tests.

Test plan

  • All existing test_file_retain.py and test_file_storage_s3.py tests pass (16/16)
  • Lint clean (ruff check + ruff format)
  • Manual verification: file retain on a tenant schema no longer returns 500

…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 nicoloboschi merged commit 86d8ac0 into vectorize-io:main Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants