Skip to content

Conversation

@thongdk8
Copy link
Contributor

@thongdk8 thongdk8 commented Nov 19, 2025

Description

This PR adds early validation for transaction mode compatibility in the data-loader import command. The validation ensures that the configured transaction manager supports transaction mode before attempting to import data.

This also works for scalardb-cluster-data-loader where currently the client cannot determine the actual transaction manager configured on the cluster side (e.g., single-crud-operation, consensus-commit). By attempting to start a transaction early, we can detect incompatible configurations and provide clear error messages before processing begins.

Related issues and/or PRs

N/A

Changes made

  • Added validateTransactionMode() method in ImportCommand that attempts to start a read-only transaction when in TRANSACTION mode to verify compatibility
  • Catches UnsupportedOperationException specifically when transaction mode is not supported (e.g., single-crud-operation configuration)
  • Handles other exceptions with new error code TRANSACTION_MODE_VALIDATION_FAILED for generic validation failures
  • Added two unit tests covering both specific (UnsupportedOperationException) and generic exception cases

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)

NA

Release notes

Added validation for transaction mode compatibility in data-loader import command to detect configuration issues early and provide clear error messages.

@thongdk8 thongdk8 requested a review from Copilot November 19, 2025 09:38
@thongdk8
Copy link
Contributor Author

/gemini review

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 introduces an early validation step in the data loader's import command to check for transaction mode compatibility. This is achieved by attempting to start a read-only transaction before the import process begins, allowing for early failure with a clear error message if the configuration is incompatible. The implementation includes a new validateTransactionMode method and associated unit tests. Additionally, the creation of TransactionFactory has been refactored to happen only once, improving efficiency and testability. The changes are well-implemented, but there is a minor issue in one of the new tests regarding how an exception is mocked, which I've commented on.

Copilot finished reviewing on behalf of thongdk8 November 19, 2025 09:45
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 adds early validation for transaction mode compatibility in the data-loader import command by attempting to start a read-only transaction during initialization. This helps detect incompatible transaction manager configurations (e.g., single-crud-operation) before data processing begins, providing clear error messages to users.

Key Changes:

  • Added validateTransactionMode() method that attempts to start and abort a transaction when in TRANSACTION mode
  • Refactored call() method to create TransactionFactory once and reuse it across validation and import operations
  • Added INVALID_TRANSACTION_MODE error enum to DataLoaderError

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
DataLoaderError.java Added new error enum INVALID_TRANSACTION_MODE for transaction mode validation failures
ImportCommand.java Added validateTransactionMode() method, refactored call() to create and reuse TransactionFactory, updated method signatures to accept transactionFactory parameter
ImportCommandTest.java Added two unit tests covering validation behavior for specific transaction errors and generic exceptions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thongdk8 thongdk8 requested review from a team, Torch3333, brfrn169, feeblefakie, inv-jishnu, komamitsu and ypeckstadt and removed request for a team November 19, 2025 10:17
@thongdk8 thongdk8 self-assigned this Nov 19, 2025
@thongdk8 thongdk8 marked this pull request as ready for review November 19, 2025 10:19
Copy link
Contributor

@ypeckstadt ypeckstadt 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

@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
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 comments. PTAL!

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! 👍

@komamitsu komamitsu self-requested a review November 20, 2025 02:37
@thongdk8 thongdk8 requested a review from brfrn169 November 20, 2025 02:42
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!

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!

Copy link
Contributor

@inv-jishnu inv-jishnu 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 0f200ff into master Nov 20, 2025
136 of 139 checks passed
@brfrn169 brfrn169 deleted the feat/data-loader-early-tx-mode-validation branch November 20, 2025 08:08
feeblefakie pushed a commit that referenced this pull request Nov 20, 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.

7 participants