Repository navigation
fix: avoid unrecoverable database write failures - #400
Conversation
Some values can throw when writing to Postgres. This includes text longer than 256 bytes for varchars and NUL byte in string based values. Before it would throw when calling save, which could be handled with try/catch, but with writes now buffered we need to check that case ahead of time.
This index has length restrictions which caused some writes to fail. This index was not used as it doesn't apply to operators with use on jsonb columns.
There was a problem hiding this comment.
Ran both halves against a local Postgres 16. They do what the description says, and the jsonb index removal is the half that actually unblocks a stuck indexer: a btree over a jsonb column rejects any row whose index tuple gets too big (index row size 4496 exceeds btree version 4 maximum 2704). The value itself is perfectly legal, so no amount of writer-side validation can save it. It trips on incompressible content rather than on big JSON, which is why it looks intermittent in production. If that's the "writes stopping our indexers", this is it.
One thing I'd fix before merge (value !== null in codegen) plus a deploy note, inline.
Nothing here touches ids, dedup or conflict handling, so it won't move the delegatedVotes drift.
Approving.
🤖 Generated with Claude Code
|
Fixed: a number into a Decimal field, a number into an Int-keyed ref and Also correcting myself on the test thread: the jsonb change is already covered, reverting that index line fails the 🤖 Generated with Claude Code |
SX API in some cases writes bad data into ORM. This previously was handled as failures would be surfaced on
.savecall.But now as writes are buffered this becomes an issue when writes are flushed and at this point it's not possible to handle that at writer level.
To avoid that we add two edge case handling in ORM setter:
varcharoverflows 256 characters.varcharorstringbased value contains NUL byte.When writer tries to set such value it will throw in-place where writer can react to it.
There was another issue with
jsonbindex size. This index isn't actually used for the queries we use (not applicable for operators we use), so we simply remove it.