Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,28 @@ public void run() {
return;
}
if (!proto.hasCommitTimestamp()) {
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);
Comment on lines +530 to +551
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);

}
span.addAnnotation("Commit Done");
opSpan.end();
Expand Down
Loading