Skip to content

Conversation

@ypeckstadt
Copy link
Contributor

@ypeckstadt ypeckstadt commented Nov 17, 2025

Description

The --mode CLI option in the Import Command is being deprecated because the import mode should be determined by the transaction manager configuration in the ScalarDB properties file, not by a separate CLI argument. This makes the data loader behavior consistent with the ScalarDB configuration and simplifies the command-line interface.

Previously, users had to specify --mode STORAGE or --mode TRANSACTION in addition to configuring their ScalarDB transaction manager. This was redundant and could lead to confusion if the CLI mode didn't match the actual transaction manager configuration.

With this change, the import mode is automatically determined from the transaction manager type:

  • If SingleCrudOperationTransactionManager is configured → uses single-crud mode
  • Otherwise → uses consensus commit mode

Related issues and/or PRs

This PR currently targets the feat/data-loader/import-replace-storage to make it easier to remove. It has to target master branch before merging.

Should we merged after the following is completed

  • Refactor Data Loader Import to Use DistributedTransactionManager for Storage Mode #3147

    Changes made

    CLI Changes

    • Deprecated the --mode (-m) option in ImportCommand
    • Added yellow warning message when deprecated --mode option is used
    • Created deprecated ScalarDbMode enum in CLI module with legacy STORAGE and TRANSACTION values for backward compatibility

    Core Changes

    • Removed scalarDbMode parameter from ImportManager constructor
    • Added automatic mode determination in ImportManager.startImport() based on transaction manager type (instanceof check)
    • Renamed core enum from ScalarDbMode to TransactionMode for clarity
    • Renamed enum values for better semantic meaning:
      • STORAGESINGLE_CRUD (clarifies single-crud operation mode)
      • TRANSACTIONCONSENSUS_COMMIT (clarifies consensus commit protocol)
    • Updated ImportProcessor and related classes to use new TransactionMode enum

    Test Changes

    • Updated test method name: startImport_shouldUseStorageMode_whenTransactionManagerIsSingleCrud()
      startImport_shouldUseSingleCrudMode_whenTransactionManagerIsSingleCrud()
    • Updated all test assertions to use new enum values (SINGLE_CRUD, CONSENSUS_COMMIT)
    • Updated mock setups to use getScalarDbMode() instead of getTransactionMode()

    Checklist

    • 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)

    The deprecated --mode option will still be accepted (with a warning) to maintain backward compatibility for existing scripts and automation.
    The option is hidden from help output. Users should remove this option from their scripts and rely on the transaction manager configuration in their ScalarDB properties file instead.

    The enum renaming (ScalarDbModeTransactionMode, STORAGESINGLE_CRUD, TRANSACTIONCONSENSUS_COMMIT) is an internal change that provides clearer semantics and better aligns with ScalarDB terminology. The CLI module maintains a separate deprecated ScalarDbMode enum for backward compatibility.

    Release notes

Deprecated --mode option in Import Command and auto-determine mode from transaction manager configuration

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ypeckstadt, 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 streamlines the data import process by eliminating the need for a redundant --mode command-line option. The system will now intelligently infer the appropriate import mode (single-crud or consensus commit) directly from the ScalarDB transaction manager configuration, enhancing consistency and simplifying the user experience. This change ensures that the data loader's behavior is always aligned with the underlying ScalarDB setup, while also providing backward compatibility for older scripts.

Highlights

  • CLI Option Deprecation: The --mode (-m) CLI option in the ImportCommand has been deprecated. Users will now see a yellow warning message if they use this option, and it has been hidden from help output.
  • Automatic Mode Determination: The import mode (single-crud or consensus commit) is now automatically determined based on the transaction manager configuration in the ScalarDB properties file, removing the need for a manual CLI argument.
  • Enum Renaming and Clarity: The internal ScalarDbMode enum has been renamed to TransactionMode for better clarity, and its values STORAGE and TRANSACTION have been renamed to SINGLE_CRUD and CONSENSUS_COMMIT respectively, to align with ScalarDB terminology.
  • Backward Compatibility: A separate, deprecated ScalarDbMode enum has been created in the CLI module to maintain backward compatibility for existing scripts that might still use the --mode option.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 effectively deprecates the --mode CLI option, simplifying the user experience by automatically determining the import mode from the transaction manager configuration. The implementation is robust, providing clear deprecation warnings while maintaining backward compatibility. The internal refactoring, including the introduction of the TransactionMode enum with more descriptive names, significantly enhances code clarity and maintainability. The accompanying tests are thorough and correctly validate the new automatic mode detection logic. I have one suggestion to further improve the code's robustness by preventing a potential NullPointerException. Overall, this is a high-quality contribution.

@@ -0,0 +1,16 @@
package com.scalar.db.dataloader.cli;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should not be merged until #3147 is completed. Have to update the target branch before that.

@ypeckstadt ypeckstadt self-assigned this Nov 17, 2025
@ypeckstadt ypeckstadt requested review from a team, Torch3333, brfrn169, feeblefakie, komamitsu and thongdk8 and removed request for a team November 17, 2025 11:27
* CLI option.
*/
@Deprecated
public enum ScalarDbMode {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While it may seem strange to create a new class that is deprecated right away, this class is added to the cli code as the original class, and its enums have been renamed in the data loader core code for clarity.

* The available transaction modes for data import operations. Determines how data is imported based
* on the transaction manager configuration.
*/
public enum TransactionMode {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This class replaces the ScalarDbMode enum class.

// refactored later
// and removed so that the whole code can just use one way to import all the data with the
// correct interface and not depend on making this distinction.
TransactionMode transactionMode =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is mainly required because in the data loader for code, we have to make a difference between transactional and non-transactional. It might be worth checking to see if we can do a refactor in the future to avoid this kind of check, though. But for now, it's required; otherwise, too much refactoring needs to be done.

@ypeckstadt
Copy link
Contributor Author

Can be ignored and will be resolved in other PRs.

@ypeckstadt ypeckstadt closed this Nov 18, 2025
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.

1 participant