ArafatKhan2198 commented on code in PR #7452:
URL: https://github.com/apache/ozone/pull/7452#discussion_r1856636279
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReconLayoutVersionManager.java:
##########
@@ -84,26 +85,41 @@ public void
finalizeLayoutFeatures(ReconStorageContainerManagerFacade scmFacade)
List<ReconLayoutFeature> featuresToFinalize = getRegisteredFeatures();
for (ReconLayoutFeature feature : featuresToFinalize) {
- try {
- // Fetch only the FINALIZE action for the feature
- Optional<ReconUpgradeAction> action =
feature.getAction(ReconUpgradeAction.UpgradeActionType.FINALIZE);
- if (action.isPresent()) {
- // Execute the upgrade action & update the schema version in the DB
- action.get().execute(scmFacade);
- updateSchemaVersion(feature.getVersion());
- LOG.info("Feature versioned {} finalized successfully.",
feature.getVersion());
+ try (Connection connection = scmFacade.getDataSource().getConnection()) {
Review Comment:
Since apache derby works on the principle of JDBC and derby provides a JDBC
driver that allows Java applications to interact with the database using
standard JDBC API calls.
Lets consider 3 Features needed to be finalised Feature 1, 2, 3 ➖
In the scenario , each feature's upgrade is managed within its own
transaction using a shared database connection (`Connection 1`). Here's how the
process unfolds:
1. **Feature 1:**
- **Transaction Begins:** A new transaction starts on `Connection 1`.
- **Execution:** Feature 1's upgrade actions are performed.
- **Commit:** Upon successful completion, the transaction is committed,
making all changes permanent.
2. **Feature 2:**
- **Transaction Begins:** A new transaction starts on the same
`Connection 1`.
- **Execution:** Feature 2's upgrade actions are performed.
- **Commit:** Upon success, this transaction is also committed,
persisting the changes.
3. **Feature 3:**
- **Transaction Begins:** Another new transaction starts on `Connection
1`.
- **Execution:** Feature 3's upgrade actions are attempted.
- **Failure:** An error occurs during execution.
- **Rollback:** The transaction is rolled back, undoing any changes made
during Feature 3's upgrade.
**Impact on Previous Features:**
The rollback of Feature 3's transaction does **not** affect the committed
transactions of Feature 1 and Feature 2. In JDBC, each transaction is
independent. Once a transaction is committed, its changes are permanent and
isolated from subsequent transactions. Therefore, the successful upgrades and
schema changes of Features 1 and 2 remain intact, even though Feature 3's
transaction was rolled back.
I have referenced this doc for the analysis ➖
https://examples.javacodegeeks.com/java-development/core-java/sql/jdbc-transaction-rollback-example/
I think I agree with you @devmadhuu we might use the same connection here
for all features.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]