Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore conflicting concurrent storage writes of the same data with version="*" #1118

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion server/core_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,11 @@ func storagePrepBatch(batch *pgx.Batch, authoritativeWrite bool, op *StorageOpWr
query = `
INSERT INTO storage (collection, key, user_id, value, version, read, write, create_time, update_time)
VALUES ($1, $2, $3, $4, $5, $6, $7, now(), now())
ON CONFLICT (collection, key, user_id) DO NOTHING
redbaron marked this conversation as resolved.
Show resolved Hide resolved
RETURNING read, write, version, create_time, update_time`

// Outcomes:
// - NoRows - insert failed due to constraint violation (concurrent insert)
// - NoRows - insert was ignored due to constraint violation (concurrent insert or non-OCC existing row)
}

batch.Queue(query, params...)
Expand Down