Skip to content
Discussion options

You must be logged in to vote

Hey @GiGurra - you can do this by enabling optimistic concurrency (session.Advanced.UseOptimisticConcurrency) on a single-node level.

It can still result in dupes in some scenarios so you're right that the only way to absolutely guarantee it is a cluster wide transaction or a manual compare exchange.

I am not familiar with the Go client so maybe someone else will comment there, but you can still do it like you propose - it just won't be atomic.

Store the document with a normal ID, then if you succeed, create a compare exchange KV with the unique key as key and the document id as value. If it fails (whether it's not unique or a network error or whatever), you can retry it.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@georgiosd
Comment options

Answer selected by ayende
@GiGurra
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants