SurrealDB DEFINE FIELD IF NOT EXISTS: Potential Write Blocking in SCHEMAFULL Mode
0 reputation · 02 Jan 2022, 02:28 UTC
SurrealDB DEFINE FIELD IF NOT EXISTS: Potential Write Blocking in SCHEMAFULL Mode
When migrating a small application to a newer SurrealDB instance, a common strategy is to add a new column with DEFINE FIELD IF NOT EXISTS so that existing rows keep returning NULL until updated. This approach works smoothly in schemaless mode, but the behavior in SCHEMAFULL mode is unclear.
In SCHEMAFULL mode, the command may trigger a validation pass that could momentarily lock the table or abort concurrent transactions. Additionally, live queries (LIVE SELECT) and changefeeds may not emit events for the new field until a value is explicitly written, potentially causing a brief period of inconsistency for real‑time consumers.
To ensure zero downtime, we need to understand whether the operation blocks concurrent writes, whether it can abort in-flight transactions, and how live queries react during the transition.
Questions:
- In SCHEMAFULL mode, does
DEFINE FIELD IF NOT EXISTSacquire an exclusive lock that blocks concurrent inserts? - Does the command trigger a brief validation pass that could abort ongoing transactions?
- How does the addition affect live queries: do changefeeds emit events for the new field only after an explicit write, and is there a window of inconsistency?