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

Add documentation for the JetStreamApiException thrown from the KeyValue.update method #1033

Open
senior opened this issue Oct 30, 2023 · 0 comments
Labels
proposal Enhancement idea or proposal

Comments

@senior
Copy link
Contributor

senior commented Oct 30, 2023

Proposed change

There should be more documentation around exactly what is thrown when there is an optimistic locking failure related to the KeyValue update method.

Use case

I want to make sure that a "write after write" collision doesn't happen when updating a key. The way that I read to do that via optimistic locking was the update method. So in my case, if the value has changed since it was last read, I would want to fail and retry to apply a change to that key's value. The way that I do that is to catch the JetStreamApiException, then reread the value and retry the update. It's not clear from the docs what other things could potentially throw that JetStreamApiException. If something that was non-recoverable threw that exception and I just always retried if update threw that exception, I could get caught in an infinite loop. I would like some additional documentation that either confirmed that exception is only thrown from the update method if there is an optimistic locking failure, or that I need to also check some other error code so that I don't retry forever.

Contribution

I'm not intending to contribute docs for this but am writing it up based on a conversation I had with Scott Fauerbach.

@senior senior added the proposal Enhancement idea or proposal label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Enhancement idea or proposal
Projects
None yet
Development

No branches or pull requests

1 participant