alexeykudinkin commented on a change in pull request #4363:
URL: https://github.com/apache/hudi/pull/4363#discussion_r771766731
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/TransactionManager.java
##########
@@ -35,44 +35,43 @@
public class TransactionManager implements Serializable {
private static final Logger LOG =
LogManager.getLogger(TransactionManager.class);
-
private final LockManager lockManager;
+ private final boolean supportsOptimisticConcurrency;
Review comment:
Name of the flag is misleading: had to go and check what it actually
refers to to fully understand its semantic -- this one is rather about
enabling/disabling CC (which you can disable if you only have a single writer)
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/TransactionManager.java
##########
@@ -35,44 +35,43 @@
public class TransactionManager implements Serializable {
private static final Logger LOG =
LogManager.getLogger(TransactionManager.class);
-
private final LockManager lockManager;
+ private final boolean supportsOptimisticConcurrency;
private Option<HoodieInstant> currentTxnOwnerInstant;
private Option<HoodieInstant> lastCompletedTxnOwnerInstant;
- private boolean supportsOptimisticConcurrency;
public TransactionManager(HoodieWriteConfig config, FileSystem fs) {
this.lockManager = new LockManager(config, fs);
this.supportsOptimisticConcurrency =
config.getWriteConcurrencyMode().supportsOptimisticConcurrencyControl();
}
- public synchronized void beginTransaction() {
+ public void beginTransaction() {
if (supportsOptimisticConcurrency) {
LOG.info("Transaction starting without a transaction owner");
lockManager.lock();
- LOG.info("Transaction started");
+ LOG.info("Transaction started without a transaction owner");
}
}
- public synchronized void beginTransaction(Option<HoodieInstant>
currentTxnOwnerInstant, Option<HoodieInstant> lastCompletedTxnOwnerInstant) {
+ public void beginTransaction(Option<HoodieInstant> currentTxnOwnerInstant,
+ Option<HoodieInstant>
lastCompletedTxnOwnerInstant) {
if (supportsOptimisticConcurrency) {
- this.lastCompletedTxnOwnerInstant = lastCompletedTxnOwnerInstant;
- lockManager.setLatestCompletedWriteInstant(lastCompletedTxnOwnerInstant);
- LOG.info("Latest completed transaction instant " +
lastCompletedTxnOwnerInstant);
- this.currentTxnOwnerInstant = currentTxnOwnerInstant;
- LOG.info("Transaction starting with transaction owner " +
currentTxnOwnerInstant);
+ LOG.info("Transaction starting for " + currentTxnOwnerInstant
+ + "with latest completed transaction instant " +
lastCompletedTxnOwnerInstant);
lockManager.lock();
- LOG.info("Transaction started");
+ this.currentTxnOwnerInstant = currentTxnOwnerInstant;
+ this.lastCompletedTxnOwnerInstant = lastCompletedTxnOwnerInstant;
+ LOG.info("Transaction started for " + currentTxnOwnerInstant
+ + "with latest completed transaction instant " +
lastCompletedTxnOwnerInstant);
}
}
- public synchronized void endTransaction() {
+ public void endTransaction() {
if (supportsOptimisticConcurrency) {
LOG.info("Transaction ending with transaction owner " +
currentTxnOwnerInstant);
- lockManager.unlock();
- LOG.info("Transaction ended");
this.lastCompletedTxnOwnerInstant = Option.empty();
- lockManager.resetLatestCompletedWriteInstant();
+ lockManager.unlock();
Review comment:
Would suggest to create `reset(Instant, Instant)` method that you can
invoke from both `lock` and `unlock`
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/TransactionManager.java
##########
@@ -35,44 +35,43 @@
public class TransactionManager implements Serializable {
private static final Logger LOG =
LogManager.getLogger(TransactionManager.class);
-
private final LockManager lockManager;
+ private final boolean supportsOptimisticConcurrency;
private Option<HoodieInstant> currentTxnOwnerInstant;
private Option<HoodieInstant> lastCompletedTxnOwnerInstant;
- private boolean supportsOptimisticConcurrency;
public TransactionManager(HoodieWriteConfig config, FileSystem fs) {
this.lockManager = new LockManager(config, fs);
this.supportsOptimisticConcurrency =
config.getWriteConcurrencyMode().supportsOptimisticConcurrencyControl();
}
- public synchronized void beginTransaction() {
+ public void beginTransaction() {
if (supportsOptimisticConcurrency) {
LOG.info("Transaction starting without a transaction owner");
lockManager.lock();
- LOG.info("Transaction started");
+ LOG.info("Transaction started without a transaction owner");
}
}
- public synchronized void beginTransaction(Option<HoodieInstant>
currentTxnOwnerInstant, Option<HoodieInstant> lastCompletedTxnOwnerInstant) {
+ public void beginTransaction(Option<HoodieInstant> currentTxnOwnerInstant,
+ Option<HoodieInstant>
lastCompletedTxnOwnerInstant) {
if (supportsOptimisticConcurrency) {
- this.lastCompletedTxnOwnerInstant = lastCompletedTxnOwnerInstant;
- lockManager.setLatestCompletedWriteInstant(lastCompletedTxnOwnerInstant);
- LOG.info("Latest completed transaction instant " +
lastCompletedTxnOwnerInstant);
- this.currentTxnOwnerInstant = currentTxnOwnerInstant;
- LOG.info("Transaction starting with transaction owner " +
currentTxnOwnerInstant);
+ LOG.info("Transaction starting for " + currentTxnOwnerInstant
+ + "with latest completed transaction instant " +
lastCompletedTxnOwnerInstant);
lockManager.lock();
- LOG.info("Transaction started");
+ this.currentTxnOwnerInstant = currentTxnOwnerInstant;
+ this.lastCompletedTxnOwnerInstant = lastCompletedTxnOwnerInstant;
+ LOG.info("Transaction started for " + currentTxnOwnerInstant
+ + "with latest completed transaction instant " +
lastCompletedTxnOwnerInstant);
}
}
- public synchronized void endTransaction() {
+ public void endTransaction() {
if (supportsOptimisticConcurrency) {
LOG.info("Transaction ending with transaction owner " +
currentTxnOwnerInstant);
- lockManager.unlock();
- LOG.info("Transaction ended");
this.lastCompletedTxnOwnerInstant = Option.empty();
- lockManager.resetLatestCompletedWriteInstant();
+ lockManager.unlock();
Review comment:
Missing `currentTxnOwnerInstant` reset
--
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]