manojpec commented on a change in pull request #4363:
URL: https://github.com/apache/hudi/pull/4363#discussion_r771769708



##########
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:
       sounds good, fixed it. 




-- 
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]


Reply via email to