fix(poll): reconcile concurrent respondent submissions
This commit is contained in:
25
README.md
25
README.md
@@ -116,6 +116,23 @@ submission. Option removal and option changes invalidate only answers bound to
|
||||
that option, and repeated removal/revocation is an idempotent replay even after
|
||||
the Poll has moved out of an editable lifecycle state.
|
||||
|
||||
## Identified response invariant
|
||||
|
||||
Poll stores at most one active response for each identified respondent in a
|
||||
Poll. PostgreSQL and SQLite enforce this with the partial unique index
|
||||
`uq_poll_responses_active_respondent`; anonymous and tombstoned responses do
|
||||
not participate in that invariant. If two submissions race, the losing insert
|
||||
is rolled back to a savepoint and follows the ordinary update policy against
|
||||
the winning row. Unrelated integrity errors are not converted into response
|
||||
updates.
|
||||
|
||||
The migration deterministically retains the latest active row by
|
||||
`submitted_at DESC, id DESC` and tombstones older duplicates. Apply it while
|
||||
Poll response writes are quiesced or while the platform maintenance lock is
|
||||
held. The released migration-head baseline must only be advanced as part of
|
||||
the reviewed release that includes this migration; it is not a development
|
||||
head ledger.
|
||||
|
||||
## Scheduling As A Poll-Backed Workflow
|
||||
|
||||
Scheduling should use Poll as the reusable response collection primitive, not
|
||||
@@ -172,3 +189,11 @@ Focused manifest verification:
|
||||
cd /mnt/DATA/git/govoplan-poll
|
||||
PYTHONPATH=src:/mnt/DATA/git/govoplan-core/src /mnt/DATA/git/govoplan-core/.venv/bin/python -m unittest discover -s tests
|
||||
```
|
||||
|
||||
Run the optional two-session PostgreSQL race check against a disposable or
|
||||
development database account that may create schemas:
|
||||
|
||||
```bash
|
||||
GOVOPLAN_POLL_TEST_POSTGRES_URL=postgresql+psycopg://user@localhost/database \
|
||||
/mnt/DATA/git/govoplan/.venv/bin/python -m pytest -q tests/test_response_uniqueness.py
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user