atepg: Switch to Serializable isolation level for transactions by default #3475
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.47) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 282 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.338
Real PR Conversation Timeline
1 comments
"Review active on #3475"
general
weight: 0.35
haiyanmeng
As discussed in the community meeting, and in issue #3044, we need to switch to using Serializable isolation by default before 1.0.
Summarizing the arguments so that they are available in the commit history:
It is actually quite difficult to write fully correct applications using Read Committed or Repeatable Read isolation levels. Even Google doesn't try (we set both internal and external Spanner to default to "External Consistency", which is even stronger than Serializable).
We have not explicitly audited for correctness at the default Read Committed isolation level, so it is very likely that there are currently subtle correctness bugs in our implementation that will only be revealed under high load.
Individual code paths can use downgraded consistency levels once we have audited their use of locking or other correctness strategies. Maintaining this auditing will be a heavy ongoing commitment, so we should only do it in places where it truly matters for performance (which might end up being nowhere).
The primary side-effect of upgrading from Read Committed to Serializable is that, when there are n racing transactions that touch the same rows, it is possible for all but one of them to fail with a conflict error. The losing clients must then retry their read-modify-write loops.
Most of the complication in this change comes from ResumeActor, which is covered by a test (TestResumeActor_ConcurrentOntoOneWorker) that checks that, of 128 concurrently resumed actors targeting a single worker, none fail with a conflict error. This test seems like a bad idea, it will always be possible for it to flake. And as a matter of system/production hygiene, retry loops should almost always be driven from the outermost client (the client calling the Substrate API in this case). However, I've preserved the existing behavior for now, which required adding some additional retry loops in the workflow, and cleaning up some error wrapping so that store-layer conflict errors properly reach the workflow code.
Fixes #3044
AI use: AI-assisted, I reviewed, heavily edited, tested, and debugged.
This change is not breaking. Enjoy the same great Substrate flavor you know and love, with fewer heart-stopping data-loss incidents.