Menu

global deadlock detection using timeout (test

t.z.liang
2011-05-12
2013-04-26
  • t.z.liang

    t.z.liang - 2011-05-12

    At first, add 2 line at line 12018 and 12019 in schema_manager.c as:
    12018               printf ("wait untill lock local class\n");
    12019               sleep (5);

    The deadlock scenario is as following:

    step 1:create a global table gt1 in node1
    create global table gt1(id int) on node 'node1';

    step 2:execute a alter command in node1
    ALTER GLOBAL TABLE gt1 ADD COLUMN col_1 varchar;
    it will sleep 5 seconds in function lockhint_subclasses.
    and then, execute another alter command in node2 before the node1 waking up.
    ALTER GLOBAL TABLE gt1 ADD COLUMN col_2 varchar;

    then 2 process in node1 and node2 will deadlock.

    the process in node1 deadlocked in lockhint_subclasses function, that means it has lock the real class mop in local server, and want to lock the remote proxy class in node2.

    the process in node2 deadlocked in locator_lock function, that means it has lock the proxy class mop in local server, and want to lock the remote real class in node1.

     
  • t.z.liang

    t.z.liang - 2011-05-13

    Set lock_timeout_in_secs=120 and try again.

    Following the steps as pre-test, and after 2 mins, the node1 will get a ERROR message:
    In the command from line 1,

    ERROR: Your transaction (index 2, (unknown)@(unknown)|0) timed out waiting on    X_LOCK lock on class gt1 because of deadlock. You are waiting for user(s)  to finish.

    0 command(s) successfully processed.
    It means node1 returned with do nothing, and node2 get the lock and execute correctly.

     
  • t.z.liang

    t.z.liang - 2011-05-13

    The lock_timeout_in_secs PRM should be set in cubrid.conf.

     

Log in to post a comment.