Skip to content

NODEJS-691 Fix generated timestamp on retry #438

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

luccailliau
Copy link
Contributor

@luccailliau luccailliau commented Apr 26, 2025

Hello @absurdfarce,

There is an issue with timestamps generated by timestamp generators in DefaultExecutionOptions.
No matter if the request is prepared or not, any retry, including speculative execution, will generate a new timestamp for the query when starting a new execution for the same request object.

As interpreted by Cassandra, the latest timestamp take precedence. Then, queries executed and marked as successful can be overwritten by past queries when retrying the execution.

The user feels that it is a retry but in fact, it is a new query.

This is done by the WriteQueue when calling request.write(...) which call writeQueryParameters(...) and then getOrGenerateTimestamp() which always generate a new timestamp for each new execution. It should generate one and use it for each consecutive calls to make a retry operation in Cassandra.

I did not write any tests for this change since I don't have a proper setup and configuration on my side which cause tests to fail. I think testing on the client side only, like this is enough:

const request = new ExecuteRequest(...);

const firstBuffers = request.write(...);
const secondBuffers = request.write(...);

assert.deepStrictEqual(firstBuffers, secondBuffers); // At least on the parts for the timestamp

Thank you very much,
Have a good day,

Luc

@absurdfarce
Copy link
Collaborator

absurdfarce commented Apr 27, 2025

Note: this PR is in reference to NODEJS-691

@absurdfarce absurdfarce changed the title Fix generated timestamp on retry NODEJS-691 Fix generated timestamp on retry Apr 30, 2025
@absurdfarce
Copy link
Collaborator

I agree that this is an issue (and a pretty significant one) but I'm inclined to say we should address it at a different spot. More details can be found on NODJES-691; I'd like to keep the conversation going there as much as possible since this issue isn't actually constrained to the code being modified here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants