Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-1767

TransactionControl and transaction isolation among threads

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • tx-control-0.0.3
    • None
    • tx-control
    • None
    • Karaf 4.2.0.M1, MySql Community Server 5.6.19, Windows 10

    Description

      Hi,

      I'm evaluating the usage of some enterprise features with Karaf.

      I wrote a test shell command (attached) in order to check the behavior of TransactionControl in a multi-threaded environment.

      I read tx-control is Thread Safe, so I wrote the command code for check isolation of new transactions created for different threads starting by the same injected TransactionControl service.

      Now, it is not working as it was intended to. Maybe for my misunderstanding about its usage.

      However:

      • I use this simple table:
        CREATE TABLE `long_term_stata` (
        `ID` bigint(20) NOT NULL AUTO_INCREMENT,
        `VERSION` bigint(20) DEFAULT NULL,
        `STATUS` varchar(255) NOT NULL,
        `PROCESSO` varchar(255) NOT NULL,
        `TARGET` varchar(255) NOT NULL,
        `NOTE` varchar(255) DEFAULT NULL,
        `EXTRA_INFO` longblob,
        PRIMARY KEY (`ID`),
        UNIQUE KEY `PROCESSO_UNIQUE` (`PROCESSO`)
        ) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;

      The command runs N thread performing in a new transaction a "select ... for update" on the same row, a read of a status, its increment and at the and an updateRow.

      I believed the first Thread kept a row write lock and the other ones waited each one to acquire the row lock until the end of their own transaction. So at the end the counter in the STATUS field of the table should have been equals to N (the number of threads).

      Instead the threads seem to be executed in parallel randomically so that the order of read & write operations is not respected, ending with a STATUS < N.

      If I set the ROW LOCK from another client is seems to work as waited. In MySqlWorkbench:
      start transaction;
      SELECT * FROM long_term_stata where id=19 for update;

      The command waits trying to acquire the row lock until I type a COMMIT in the workbench.

      So, my conclusion (but easily I made some mistake) is that the transaction isolation does not work properly among threads starting transactions from the same instance of injected TransactionControl.

      Could you help me confirming if it is a strange behavior or advising for the right way to write the test?

      Thanks in advance

      Attachments

        1. TestTXCommand.java
          6 kB
          Piergiuseppe Spinelli

        Activity

          People

            Unassigned Unassigned
            pierospinelli Piergiuseppe Spinelli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: