◐ Off-By-One · answer catalog

python-postgres-ssi-rw-antidependency-pivot-cycle-certificate

1 answer(s)python3python3

python-postgres-ssi-rw-antidependency-pivot-cycle-certificate

📦 Source in repository (JSON)

Answer

Done. I diagnosed the problem and produced a verified, self-contained solution.

What I found

The task (/workspace/problem.json) has no test harness or required signature, so I grounded the implementation in PostgreSQL's actual source rather than guessing. I fetched src/backend/storage/lmgr/predicate.c and implemented the semantics of PreCommit_CheckForSerializationFailure() and the SXACT_FLAG_READ_ONLY handling exactly.

Root causes of the hard parts

  1. Snapshot-relative edges — R --rw--> W exists only when W writes something R read and W.commit >= R.begin (invisible writer). This is the boundary most implementations get wrong.
  2. Dangerous structure, not any cycle — only Tin --rw--> Tpivot --rw--> Tout with Tout committing first matters.
  3. First-committer-wins — commit order decides the victim (classic write-skew 2-cycle aborts the second committer).
  4. Read-only far transactions are excluded, otherwise PG would abort transactions it actually keeps.
  5. The pivot is doomed (not the early committer), then aborts at its own commit point.

Deliverables (in /workspace)

Verification

All tests pass, covering write skew in both commit orders, disjoint/no-anomaly schedules, read-only transactions, a read-only Tin, a non-read-only 3-node dangerous structure, all six commit orders of a 3-cycle, snapshot visibility, and JSON/CLI round-trip. I also re-extracted the code block from the markdown itself and ran it to confirm the document is executable as written — it produced aborts: [2] and passed verify().

Evidence & signatures

# Evidence
- Problem class: python-postgres-ssi-rw-antidependency-pivot-cycle-certificate
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-26T10:06:06.855Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement PostgreSQL-style Serializable Snapshot Isolation conflict analysis over a supplied transaction schedule: build the rw-antidependency graph from read/write dependencies and snapshot boundaries, then decide whether a dangerous structure exists (a cycle with two or more consecutive rw-antidependency edges and a pivot transaction whose early commit closes the anomaly). Emit the exact set of transactions PostgreSQL would abort, ordered by commit time then pid, together with a machine-checkable certificate listing the antidependency edges and the cycle witness. Must handle read-only transactions, mutually opposing rw edges between a pair, and schedules with no anomaly (empty abort set).", "environment": "python3", "language": "python3", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "python-postgres-ssi-rw-antidependency-pivot-cycle-certificate", "provider": "openrouter", "solved_at": "2026-09-26T10:06:06.855Z", "version": "3.11"}
Generated from the verified corpus · MIT licensedBack to the catalog