Skip to content

fix: run only the missing schema changes on startup - #90

Merged
danfimov merged 1 commit into
mainfrom
fix/schema-setup-privileges
Nov 25, 2026
Merged

danfimov merged 1 commit into
mainfrom
fix/schema-setup-privileges

Conversation

@danfimov

Copy link
Copy Markdown
Owner

ALTER TABLE and CREATE INDEX require owning the table even with IF NOT EXISTS. CREATE TABLE IF NOT EXISTS requires CREATE on the schema. So startup failed for an application role with only DML privileges, even when the table and indexes had been prepared in advance. For CREATE TABLE this was already the case on main, although docs/tutorial/common_issues.md suggests creating tables manually.

Under the schema lock, startup now checks which parts exist (to_regclass, pg_attribute) and runs DDL only for the missing ones.

Test: an owner prepares the table and indexes, and a role with only SELECT/INSERT/UPDATE/DELETE and sequence USAGE runs startup, kick and listen. The test fails without the fix for all four drivers.

Part of a stack; review and merge bottom-up. Stress-harness numbers are from a local run: 4 drivers, ~250–550 kicks per scenario, 2 worker processes per driver.

@greptile-apps

greptile-apps Bot commented Nov 25, 2026

Copy link
Copy Markdown

security Security Review

This PR appears safe to merge from a security standpoint.

What was checked
  • The new schema-existence query binds the table and index names as parameters in all four drivers, so no value is interpolated into SQL text.
  • The existence check and any DDL still run inside the same transaction under the advisory lock, so concurrent broker startups keep serializing like before.
  • Startup fails closed in every driver when the status query errors or returns no row; nothing fails open.
  • Skipping DDL for existing parts only lowers the privileges startup needs; a wrongly-detected existing index would cost performance, not access control.
  • The test file adds no production secrets or new dependencies.

@danfimov
danfimov force-pushed the fix/schema-setup-privileges branch 4 times, most recently from c4c1415 to b537408 Compare November 25, 2026 22:26
@danfimov
danfimov force-pushed the fix/schema-setup-privileges branch 3 times, most recently from 5e1d916 to a0f9dc2 Compare November 25, 2026 22:39
Base automatically changed from feat/processing-timeout to main November 25, 2026 22:40
ALTER TABLE and CREATE INDEX require owning the table even with IF NOT
EXISTS, and CREATE TABLE IF NOT EXISTS requires the CREATE privilege on the
schema. So startup failed for an application role that only has DML
privileges, even when the table and indexes had been prepared in advance;
for CREATE TABLE this was already the case before.

Check which parts already exist (to_regclass, pg_attribute) under the schema
lock and run DDL only for the missing ones.
@danfimov
danfimov force-pushed the fix/schema-setup-privileges branch from a0f9dc2 to a562173 Compare November 25, 2026 22:40
@danfimov danfimov self-assigned this Nov 25, 2026
@danfimov
danfimov merged commit 4259a31 into main Nov 25, 2026
12 checks passed
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.

1 participant