Repository navigation
Conversation
…removed On PostgreSQL at read committed, two publishers that both find the issue of an in-flight attempt both record it; the second's versioned removal of the report finds nothing and failed the whole call with NOT_FOUND. A report removed between its read and its removal is now taken as gone: the published entry is still recorded. A removal elsewhere in the report store that finds nothing answers CONFLICT, which every caller already retries or leaves to the next pass, and clearing the note of the last publishing error after another publisher did so fails nothing. Closes #78 Signed-off-by: Goon <duy@wearetopgroup.com>
…/report-publish-race
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #78.
What was wrong
On PostgreSQL at read committed, two publishers sharing the store could both read a report. The one that lost the race found the document already removed: its versioned
DeleteKVremoved nothing and answeredNOT_FOUND, which the publisher treated as a failure. SQLite serializes transactions, so it never showed.Fix
internal/control/report_store.go:deleteReadturns aNOT_FOUNDon a versioned delete intoCONFLICT("read it again").dropReport,dropIndexOf, the client store and the refusal path use it, and their callers already retry onCONFLICT.markPublished: a report another publisher removed meanwhile is still recorded as published.noteError: clearing an error note that changed or disappeared meanwhile fails nothing.Tests
internal/control/report_publish_removed_meanwhile_test.gowraps the store so that the first armed delete really removes the document and then answersNOT_FOUND, which is what the losing PostgreSQL transaction sees. Each of the three tests fails without the fix. They run on SQLite, so CI covers the race deterministically. CI's test-postgres job does not runinternal/control, which takes about 12 minutes on PostgreSQL; locally the whole package passed on PostgreSQL with-race.Locally:
go build,go vet,gofmtandgolangci-lintare clean.go test ./...passes.-racepasses oninternal/controlon SQLite and on PostgreSQL.internal/control/apipasses with-race(590 s, unrelated to this change).