Github user chtyim commented on a diff in the pull request:

    https://github.com/apache/incubator-tephra/pull/23#discussion_r91457499
  
    --- Diff: 
tephra-core/src/main/java/org/apache/tephra/TransactionManager.java ---
    @@ -348,27 +348,30 @@ private void cleanupTimedOutTransactions() {
             }
     
             long currentTime = System.currentTimeMillis();
    -        List<Long> timedOut = Lists.newArrayList();
    +        Map<Long, InProgressType> timedOut = Maps.newHashMap();
    --- End diff --
    
    Unrelated to the change, but it seems like the locking in this method is 
wrong.
    
    First, we are holding the read lock for the entire cleanup method, which 
seems unnecessary. The inProgress itself is a concurrent tree, so for the first 
`for-loop`, it shouldn't need the lock at all, as it is just for collecting the 
in progress tx that are timed out.
    
    Then in the `if (!timedOut.isEmpty())`, seems like only the modification to 
`invalid` and `invalidArray` needs to be protected by lock, but I think it 
should be a "write lock"?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to