0 Replies Latest reply on Jul 13, 2010 12:00 PM by Ben Spiller

    Possible concurrency bug in ResourceManagerImpl heuristicCompletions

    Ben Spiller Newbie

      I'm a complete newbie to this codebase, so please forgive me if this is not a helpful contribution...

       

      But I was looking at org.hornetq.core.transaction.impl.ResourceManagerImpl to better understand how the XA transaction support works, and I noticed that the heuristicCompletions field is modified and also read (via an iterator) without any locking - and as far as I can see it probably could be accessed from multiple threads at once (e.g. getHeristicCommittedTransactions/xaForget are both called from the packet handler):

       

         private final ConcurrentMap<Xid, Transaction> transactions = new ConcurrentHashMap<Xid, Transaction>();
         private final List<HeuristicCompletionHolder> heuristicCompletions = new ArrayList<HeuristicCompletionHolder>();
      

       

      It's interesting that the transactions field in the same class DOES have protection from concurrent access but the heuristicCompletions field doesn't, though they're both read/written from the same places (e.g. the xaCommit method).

       

      I should stress that I haven't actually seen a real-life bug in this code, but I thought I'd mention it as it does look a bit wrong...