Repository navigation
fix(databases): report a column changed mid-write as column not found - #14376
Conversation
A row write that read the table's schema before a column was deleted
or renamed fills in that column's default, and Postgres rejects the
insert with an undefined column. The database library raises that as
NotFound('Attribute not found'), which createRow reported as
table_not_found. Report it as column_not_found (attribute_not_found
on the Collections API) and keep table_not_found for a missing table.
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
The change refines the
Reviewed commit: 2230cef |
🟢 Tier S · Ready to mergeCreate, update, and upsert document/row handlers now recheck collection metadata after database Latest changes: The newest commits replace operation- and collection-specific schema-change text with one consistent retry-oriented message across all four handlers.
📂 Walkthrough · 4
Merged |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…le document Match on the table document instead of the database library's exception message: a NotFound from the insert is table_not_found only when the table document is gone, and a changed column otherwise.
Update, upsert and bulk upsert let the database library's NotFound escape as a 500 when a column was deleted while the write ran. Catch it as createRow does: table_not_found when the table document is gone, column_not_found otherwise.
…-found # Conflicts: # src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php # src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php # src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php
What changed
When a column is deleted (or renamed) while rows are being written, a writer that read the schema before the change still writes the old column (its default on create/upsert, its cached value on update). Postgres rejects the statement with
42703(undefined column) and the database library raisesNotFound('Attribute not found'):createDocument/createRowcaught everyNotFoundExceptionas a missing table and returned404 table_not_foundfor a table that still exists.updateDocument/updateRow,upsertDocument/upsertRowand bulk upsert didn't catch it and returned500 general_unknown.All four now catch it the same way and re-read the table document, the same check they run before the write:
table_not_found/collection_not_found.column_not_found(attribute_not_foundon the Collections API), "The schema changed while this request was running. Please try again."Bulk update only writes the columns it is sent and was not affected.
Verification
Local stack, Postgres, API on this branch in a separate container, worker from the shared stack. Table with integer
kand varchary(default: "d"), 4 writers sending onlykand 2 readers, thenDELETE …/columns/ymid-load.main404 table_not_found404 column_not_found500 general_unknown404 column_not_found500 general_unknown404 column_not_found500 general_unknown404 column_not_foundPostgres logs
column "y" of relation … does not existfor the failing statements, and the API logsNotFound: Attribute not foundfor the 500s. One round of create through/v1/databases/…/documentsreturns404 attribute_not_found. Deleting the table mid-load (create and upsert writers): every failed read and write is404 table_not_found. Reads are unaffected throughout.pint --testandphpstan analysepass on the changed files.Fixes #14336