Skip to content

Conversation

@komamitsu
Copy link
Contributor

@komamitsu komamitsu commented Aug 27, 2025

Description

I noticed committing records silently fail when deleting a record without clustering key. It doesn't cause integration test failures since committing state itself finishes successfully and the failure of commit-record is ignored. This PR fixed the issue.

Related issues and/or PRs

https://github.com/scalar-labs/scalardb/pull/2957/files#diff-a77001aa78b9f7b380bda3d90371dd74610f8a344d04a5aa42c2ae8b704d901eR121, I guess.

Changes made

Avoid setting clusteringKey() to null in CommitMutationComposer#composeDelete().

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • 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)

None

Release notes

N/A

@komamitsu komamitsu self-assigned this Aug 27, 2025
Copy link
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.

Summary of Changes

Hello @komamitsu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a NullPointerException (NPE) that occurred when attempting to delete records without a clustering key. Previously, committing such delete operations would silently fail because the clusteringKey() method was explicitly set to null, leading to an issue during the commit process. The fix ensures that the clustering key is only set if it is present, preventing the NPE and allowing these delete operations to complete successfully.

Highlights

  • NPE Fix for DELETE operations: Resolved a NullPointerException that occurred when performing DELETE operations without a clustering key by modifying the composeDelete method in CommitMutationComposer to conditionally set the clustering key.
  • Improved Clustering Key Handling: The composeDelete method now uses Optional.ifPresent to apply the clustering key only when it exists, avoiding the explicit passing of null.
  • Enhanced Test Coverage: Added new test cases in CommitMutationComposerTest to specifically validate the correct behavior of Put and Delete operations when no clustering key is provided.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 correctly fixes a NullPointerException that could occur during a DELETE operation on a record without a clustering key. The modification in CommitMutationComposer to use ifPresent for conditionally setting the clustering key is a clean and appropriate solution. The new tests added in CommitMutationComposerTest are well-written and provide good coverage for the fix, especially the case for deletes without a clustering key. I've included one suggestion to improve the maintainability of the test code by refactoring duplicated logic.

@komamitsu komamitsu requested a review from Copilot August 27, 2025 03:03

This comment was marked as outdated.

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!

@komamitsu komamitsu requested a review from Copilot August 27, 2025 07:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a NullPointerException that occurs when deleting records without clustering keys in the consensus commit transaction system. The issue was causing silent failures during commit operations where null clustering keys were being passed to builder methods that don't accept null values.

Key changes made:

  • Modified CommitMutationComposer and RollbackMutationComposer to conditionally set clustering keys only when present
  • Updated both composers to use builder patterns that avoid passing null values
  • Added comprehensive test coverage for operations without clustering keys

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
CommitMutationComposer.java Fixed NPE by conditionally setting clustering key in delete operations using Optional.ifPresent()
RollbackMutationComposer.java Applied same fix to rollback operations and updated get operation to handle null clustering keys
CommitMutationComposerTest.java Added test cases for put and delete operations without clustering keys
RollbackMutationComposerTest.java Added test case for put operations without clustering keys in rollback scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

LGTM! Thank you for handling this!

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!

@komamitsu komamitsu merged commit 316229b into master Aug 27, 2025
106 of 108 checks passed
@komamitsu komamitsu deleted the fix-delete-wo-clustering-key branch August 27, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants