BTM
  1. BTM
  2. BTM-29

Random CorruptedTransactionLogException thrown during swapJournalFiles under JDK 1.6

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3.1
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      0

      Description

      The root cause of the problem is that the HashSet implementation changed between JDK 1.4 and JDK 1.6.

      TransactionLogRecord.calulateCrc32() iterates over the HashSet containing uniqueNames to calculate the CRC32. In JDK 1.4, the order in which unique names are added to the HashSet does no matter: the iteration will always return them in a static order. Under JDK 1.6, the order of the elements during the iteration COULD depend on the insertion order in the HashSet:

      In JDK 1.4, iterating this HashSet:

      Set uniqueNames = new HashSet();
      names.add("abc");
      names.add("xyz");

      will always return xyz then abc

      In JDK 1.6, we could get abc then xyz or xyz then abc. This depends on the hash value, add order and other internal implementation details.

      Since the CRC32 of (abc xyz) is NOT the same as the one of (xyz abc) it could be that during swapJournalFiles() while the TransactionLogRecord are being re-read that they are iterated in another order than the insertion one thus leading to a different CRC32.

        Activity

        Hide
        Ludovic Orban added a comment -

        Changing the TransactionLogRecord constructors to accept SortedSet instead of Set will fix this issue. The only caveat is that this change requires a minor change in the Journal interface:

        public void log(int status, Uid gtrid, Set uniqueNames) throws IOException;

        has to be changed to:

        public void log(int status, Uid gtrid, SortedSet uniqueNames) throws IOException;

        See: http://www.nabble.com/Corrupted-log-td19329045.html

        Show
        Ludovic Orban added a comment - Changing the TransactionLogRecord constructors to accept SortedSet instead of Set will fix this issue. The only caveat is that this change requires a minor change in the Journal interface: public void log(int status, Uid gtrid, Set uniqueNames) throws IOException; has to be changed to: public void log(int status, Uid gtrid, SortedSet uniqueNames) throws IOException; See: http://www.nabble.com/Corrupted-log-td19329045.html
        Hide
        Ludovic Orban added a comment -

        Fixed in trunk.

        Show
        Ludovic Orban added a comment - Fixed in trunk.
        Hide
        Ludovic Orban added a comment -

        Reverted changes that required the Journal interface to change. The SortedSet usage is now purely a TransactionLogRecord internal detail as it should be.

        Show
        Ludovic Orban added a comment - Reverted changes that required the Journal interface to change. The SortedSet usage is now purely a TransactionLogRecord internal detail as it should be.

          People

          • Assignee:
            Ludovic Orban
            Reporter:
            Ludovic Orban
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: