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

Remove unnecessary loggings in statement handlers #2469

Merged
merged 7 commits into from
Jan 22, 2025

Conversation

KodaiD
Copy link
Contributor

@KodaiD KodaiD commented Jan 20, 2025

Description

This PR removes unnecessary loggings in statement handlers.

In some statement handlers, the logger outputs exceptions thrown by the backend databases. However, because those exceptions are set to the cause of ExecutionException, there is no need to output them to the log.

The unnecessary error log can confuse users. For example, when a transaction gets a record with tx_state=1, Cosmos DB throws 412(Precondition Failed), but this is an expected behavior, and there is no need to output this error to the ScalarDB log.

Related issues and/or PRs

N/A

Changes made

I remove loggings in:

  • cassandra/SelectStatementHandler
  • cosmos/BatchHandler
  • cosmos/MutateStatementHandler

Other statement handlers don't do this kind of logging.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

Removed unnecessary loggings in the statement handlers for Cassandra and Cosmos DB.

@KodaiD KodaiD self-assigned this Jan 20, 2025
@KodaiD KodaiD requested review from a team, komamitsu, brfrn169, feeblefakie and Torch3333 and removed request for a team January 20, 2025 06:26
Comment on lines 293 to 294
default:
logger.warn("Unsupported ordering specified. Using Order.ASC");
return QueryBuilder.asc(quoteIfNecessary(ordering.getColumnName()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the warning message for now, but I think that handling unexpected ordering values by treating them as ASC should not be performed after the operation checker's validation process. In this default branch, would it be better to throw an AssertionError instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should throw AssertionError in that case. Thanks.

@KodaiD KodaiD changed the title Remove unnecessary loggings in statement handlers. Remove unnecessary loggings in statement handlers Jan 20, 2025
@KodaiD
Copy link
Contributor Author

KodaiD commented Jan 21, 2025

@brfrn169 Thanks for reviewing.

https://github.com/scalar-labs/scalardb/blob/remove-unnecessary-logging/core/src/main/java/com/scalar/db/storage/cassandra/StatementHandler.java#L122-L123

It seems that OperationChecker does not validate the consistency of the Operation, and I think it's this function's responsibility to check the contents of consistency and handle unexpected cases. Therefore, I think it would be fine to leave the logging warning message here. What do you think?

https://github.com/scalar-labs/scalardb/blob/remove-unnecessary-logging/core/src/main/java/com/scalar/db/storage/cassandra/MutateStatementHandler.java#L74

Ah, this line can be removed, thanks for pointing it out. I'll check if similar warning message loggings remain.

@brfrn169
Copy link
Collaborator

@KodaiD

It seems that OperationChecker does not validate the consistency of the Operation, and I think it's this function's responsibility to check the contents of consistency and handle unexpected cases. Therefore, I think it would be fine to leave the logging warning message here. What do you think?

Similar to https://github.com/scalar-labs/scalardb/pull/2469/files#r1921856962, the Consistency enum has three types (SEQUENTIAL, EVENTUAL, and LINEARIZABLE), and the switch statement covers all of them. So, I think we can throw an AssertionError in that case. Thanks.

Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@KodaiD
Copy link
Contributor Author

KodaiD commented Jan 21, 2025

@brfrn169
I replace the warning message loggings with AssertionError in bf353c4.
Also, removed unnecessary loggings in e70d365. PTAL!

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

Left several minor comments. Other than that, LGTM! Thank you!

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@brfrn169 brfrn169 merged commit 99f8b45 into master Jan 22, 2025
48 checks passed
@brfrn169 brfrn169 deleted the remove-unnecessary-logging branch January 22, 2025 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants