Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-485

[ADO.NET] the usage of CUBRIDConnection.SetLockTimeout() and CUBRIDConnectionSetLockTimeout(int value) are not clear

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: ADONET-8.4.3, ADONET-9.1.0
    • Fix Version/s: ADO.NET 9.2.0.0002
    • Component/s: ADO.NET
    • Labels:

      Description

      In CUBRIDConnection class, some questions confused me:
      1. SetLockTimeout() and SetLockTimeout(int value) must be used togather. Open method does not set the lock timeout value to the server. and I have to set lock timeout value with SetLockTimeout(int value) before open a connection and call SetLockTimeout() after open a connection.
      2. The value I set for lock timeout is not used. I set lockTimeout as 60 s, but the lock timeout exception is thrown in about 2 seconds.

      Please have a look at the attached test case for details.

      More information:
      The exception I get in the test case is the same as what I get directly in csql (does not use the interface), just the waiting time is not the same as the time I wait in csql.

      The exception is:
      Your transaction (index 2, PUBLIC@user-PC|528) timed out waiting on IX_LOCK lock on class t. You are waiting for user(s) PUBLIC@user-PC|cub_cas(312) to finish.

        Activity

        Hide
        kevinyang Kai Yang (Inactive) added a comment -

        Merged into a single function.

        Show
        kevinyang Kai Yang (Inactive) added a comment - Merged into a single function.
        Hide
        kevinyang Kai Yang (Inactive) added a comment -

        Merged into a single function.

        Show
        kevinyang Kai Yang (Inactive) added a comment - Merged into a single function.
        Hide
        cn15701 cuiman added a comment -

        LockTimeout can only be set after connection is opened. I think the lock timeout value should be set either before or after the connection is opened.

        Show
        cn15701 cuiman added a comment - LockTimeout can only be set after connection is opened. I think the lock timeout value should be set either before or after the connection is opened.
        Hide
        cn15800 谢韦华[Bert] added a comment -

        There are problems in test code.

        Class1.cs

        MSDN:A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.

        It's mean:

        {code}
        startTime = DateTime.Now.Ticks;
        System.Threading.Thread.Sleep(2000);
        endTime = DateTime.Now.Ticks;
        (endTime - startTime)/(1000*10000) == 2 second{code}

        So the correct test code

        {code}
        endTime = DateTime.Now.Ticks;
        int eclapseTime = (int)((endTime - startTime) / (10000));
        int diffTime = Math.Abs(eclapseTime - conn.LockTimeout);
        Console.WriteLine(eclapseTime.ToString());
        Console.WriteLine(conn.LockTimeout.ToString());
        Console.WriteLine(ex.Message);

        if (diffTime < 1000) // less than 1 second
        { Console.WriteLine("pass."); }
        else
        { Console.WriteLine("failed."); }{code}
        Show
        cn15800 谢韦华[Bert] added a comment - There are problems in test code. Class1.cs MSDN:A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond. It's mean: {code} startTime = DateTime.Now.Ticks; System.Threading.Thread.Sleep(2000); endTime = DateTime.Now.Ticks; (endTime - startTime)/(1000*10000) == 2 second{code} So the correct test code {code} endTime = DateTime.Now.Ticks; int eclapseTime = (int)((endTime - startTime) / (10000)); int diffTime = Math.Abs(eclapseTime - conn.LockTimeout); Console.WriteLine(eclapseTime.ToString()); Console.WriteLine(conn.LockTimeout.ToString()); Console.WriteLine(ex.Message); if (diffTime < 1000) // less than 1 second { Console.WriteLine("pass."); } else { Console.WriteLine("failed."); }{code}
        Hide
        cn15800 谢韦华[Bert] added a comment -

        The SetLockTimeout(20*1000):

        1.driver send to sql to cubrid(ExecuteSQL)
        2.transmission(Network) ------->Uncontrollable
        3.cubrid wait to timed out -------> 20S
        4.cubrid sent response to driver
        5.transmission(Network) ------->Uncontrollable
        6.driver throw exception (time out)

        So the result is bigger than 20S.

        Show
        cn15800 谢韦华[Bert] added a comment - The SetLockTimeout(20*1000): 1.driver send to sql to cubrid(ExecuteSQL) 2.transmission(Network) ------->Uncontrollable 3.cubrid wait to timed out -------> 20S 4.cubrid sent response to driver 5.transmission(Network) ------->Uncontrollable 6.driver throw exception (time out) So the result is bigger than 20S.
        Hide
        cn15800 谢韦华[Bert] added a comment -

        MSDN: http://msdn.microsoft.com/zh-cn/library/ms378009.aspx

        Specifies the connection lock timeout as millisecond.

        Our doc is wrong.

        Show
        cn15800 谢韦华[Bert] added a comment - MSDN: http://msdn.microsoft.com/zh-cn/library/ms378009.aspx Specifies the connection lock timeout as millisecond. Our doc is wrong.
        Hide
        cn15800 谢韦华[Bert] added a comment -

        I can improve the issue:

        the lock timeout value should be set either before or after the connection is opened.

        Show
        cn15800 谢韦华[Bert] added a comment - I can improve the issue: the lock timeout value should be set either before or after the connection is opened.
        Hide
        cn15800 谢韦华[Bert] added a comment - - edited

        If user don't set lock timeout value,the default value is 30*1000(30S),not -1. we can set default value as -1.

        Show
        cn15800 谢韦华[Bert] added a comment - - edited If user don't set lock timeout value,the default value is 30*1000(30S),not -1. we can set default value as -1.
        Hide
        ryin005 Ray Yin added a comment - - edited
        • Test OS: Windows 32bit, Windows 64bit
        • CUBRID: 9.2.0.0155
        • Driver: cubrid-ado.net 9.2.0.0002
        • .NET 4.0

        Test Result: Pass

        Close the issue

        Show
        ryin005 Ray Yin added a comment - - edited Test OS: Windows 32bit, Windows 64bit CUBRID: 9.2.0.0155 Driver: cubrid-ado.net 9.2.0.0002 .NET 4.0 Test Result: Pass Close the issue

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            cn15701 cuiman
            CC (Referrer):
            cuiman, Kai Yang (Inactive), 李应
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: