Skip to content

chore(spanner): add missing commit ts logging#13037

Open
sakthivelmanii wants to merge 1 commit intomainfrom
spanner-empty-commit-ts-logging
Open

chore(spanner): add missing commit ts logging#13037
sakthivelmanii wants to merge 1 commit intomainfrom
spanner-empty-commit-ts-logging

Conversation

@sakthivelmanii
Copy link
Copy Markdown
Contributor

No description provided.

@sakthivelmanii sakthivelmanii requested review from a team as code owners May 8, 2026 07:50
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances error reporting and logging in TransactionRunnerImpl.java when a commitTimestamp is missing by including details about precommit tokens and retry attempts. Feedback suggests addressing a missing state in the logging logic and refactoring the code to reduce redundancy and improve maintainability.

Comment on lines +530 to +551
if (proto.hasPrecommitToken() && retryAttemptDueToCommitProtocolExtension) {
txnLogger.log(
Level.FINE,
"Missing commitTimestamp, response has precommit token "
+ "and client has already attempted commit retry");
span.addAnnotation(
"Missing commitTimestamp, response has precommit token "
+ "and client has already attempted commit retry");
} else if (!proto.hasPrecommitToken()) {
txnLogger.log(
Level.FINE, "Missing commitTimestamp, response has no precommit token");
span.addAnnotation(
"Missing commitTimestamp, " + "response has no precommit token");
}
throw newSpannerException(
ErrorCode.INTERNAL, "Missing commitTimestamp:\n" + session.getName());
ErrorCode.INTERNAL,
"Missing commitTimestamp:\n"
+ session.getName()
+ "\nHas precommit token: "
+ proto.hasPrecommitToken()
+ "\nAlready attempted commit retry: "
+ retryAttemptDueToCommitProtocolExtension);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation misses logging and annotations for the case where proto.hasPrecommitToken() is true but retryAttemptDueToCommitProtocolExtension is false. This is an important state to capture for debugging the commit protocol extension. Additionally, the logic can be simplified to reduce redundancy and avoid unnecessary string literal concatenation.

                    String message =
                        "Missing commitTimestamp, response has "
                            + (proto.hasPrecommitToken() ? "precommit token" : "no precommit token")
                            + (proto.hasPrecommitToken() && retryAttemptDueToCommitProtocolExtension
                                ? " and client has already attempted commit retry"
                                : "");
                    txnLogger.log(Level.FINE, message);
                    span.addAnnotation(message);
                    throw newSpannerException(
                        ErrorCode.INTERNAL,
                        message
                            + ":\n"
                            + session.getName()
                            + "\nHas precommit token: "
                            + proto.hasPrecommitToken()
                            + "\nAlready attempted commit retry: "
                            + retryAttemptDueToCommitProtocolExtension);

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