none
MSSQL Linux ODBC: Support query interruption with SQLCancel() RRS feed

  • Question

  • We have C++ code originally based on Windows ODBC which talk with MSSQL2017. we have feature to use SQLCancel () API to cancel some query run by SQLExecute function if we believe it is running too long.

    The code like that Thread A:  SQLExecute()    

                                Thread B: if think Thread A Query is too long, or Admin manually want to stop query. it will call SQLCancel () which will cancel that Query. For Thread A, that SQLExecute() function will return with following error as expected.

    ODBC error. SQLSTATE: HY008 Native error: 0
    Message: [Microsoft][ODBC SQL Server Driver]Operation canceled

    Notice we use Sync connection for any ODBC operation.

    When we move our code to Linux platform, we use latest MSSQL Linux ODBC driver 17.3. and for the same case,

    Thread A run SQLExectue() 

    Thread B call SQLCancel()

    I can see SQLCancel() function return successfully, but SQLExectue() from Thread A will not return and keep hanging. So i need manually Ctrl+C to stop the application. From the syslog, I can see

    [ 0] 7efcf80ba8e7 near UGS::Error::Exception::doTraceback(bool) const+0x74  (libsyss.so)
    [ 1] 7efcf80dd83a near UGS::Error::Signal::Signal(char const*, int, int, char const*, __va_list_tag*)+0x3f  (libsyss.so)
    [ 2] 7efcf80dd870 near UGS::Error::Signal::raise(char const*, int, int, char const*, __va_list_tag*)+0x19  (libsyss.so)
    [ 3] 7efcf80dd919 near UGS::Error::Signal::raise(char const*, int, int, char const*, ...)+0x7c  (libsyss.so)
    [ 4] 7efcf809b2dd near general_fault_handler(int)+0x145                (libsyss.so)
    [ 5] 7efcf2bae950                                                      (libc.so.6)
                 -- signal --
    [ 6] 7efcf37c9fbb near __libc_recv+0x1a                                (libpthread.so.0)
    [ 7] 7efceed38402                                                      (libmsodbcsql-17.3.so.1.1)
    [ 8] 7efceedbe3fe                                                      (libmsodbcsql-17.3.so.1.1)
    [ 9] 7efceed94d93                                                      (libmsodbcsql-17.3.so.1.1)
    [10] 7efceed68ec4                                                      (libmsodbcsql-17.3.so.1.1)
    [11] 7efceed533af                                                      (libmsodbcsql-17.3.so.1.1)
    [12] 7efceed538b4                                                      (libmsodbcsql-17.3.so.1.1)
    [13] 7efceed5f13b                                                      (libmsodbcsql-17.3.so.1.1)
    [14] 7efceec9f9ef                                                      (libmsodbcsql-17.3.so.1.1)
    [15] 7efceeca01b7                                                      (libmsodbcsql-17.3.so.1.1)
    [16] 7efceecac1a2                                                      (libmsodbcsql-17.3.so.1.1)
    [17] 7efceecac855                                                      (libmsodbcsql-17.3.so.1.1)
    [18] 7efcf4010c29 near SQLExecute+0x1e8                                (libodbc.so.2)

    Thread A, hanging around SQLExecute () and never return even Thread B already cancel that query. I check the online document, it say to Cancel the Query, you connection need to be Async, but my question is, why Windows ODBC driver supportCancel the Query even it is Sync Connection, but for Linux ODBC driver, it doesn't work. 

    Friday, July 19, 2019 4:00 PM

All replies

  • Good day ?!?

    This question related to C++ command and not to SQL Server Script (using Transact SQL). This is not related to SQL Server forums but to C++ forum where people familiar with C++ commands.

    Asking the question here in SQL Server command is like asking about how to open notepad using C++ , in a forum that only focused on notepad question. You will not do this probably, and if you want to do something in C++ then you need to use C++ and get help from C++ users

    Please close this thread, or inform us if you want us to move the thread to the Visual C++ forum
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=vcgeneral


    signature   Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]    [Linkedin]

    Sunday, July 21, 2019 11:19 AM
  • but my question is, why Windows ODBC driver supportCancel the Query even it is Sync Connection, but for Linux ODBC driver, it doesn't work. 

    Are you using ODBC Driver 17 for SQL Server on both Windows and Linux? This may help narrow the problem to the driver, app code difference, or OS platform behavior difference. 

    I moved this thread to the Data Access forum since it's related to unmanaged SQL Server drivers.


    Dan Guzman, Data Platform MVP, http://www.dbdelta.com



    Sunday, July 21, 2019 11:32 AM
    Moderator
  • Thanks Dan Guzman , yes that's right. our CPP code link with MSSQL ODBC driver and try to work on both Windows and Linux, but so far for the exact same ODBC API function, the behavior between Windows and Linux are difference, that why really confused us
    • Edited by oldhawkcn Sunday, July 21, 2019 9:17 PM
    Sunday, July 21, 2019 7:23 PM
  • Thanks Dan Guzman , yes that's right. our CPP code link with MSSQL ODBC driver and try to work on both Windows and Linux, but so far for the exact same ODBC API function, the behavior between Windows and Linux are difference, that why really confused us

    Hi oldhawkcn,

    Thanks for your reply.

    MSSQL ODBC driver on Windows platform is more mature than one on Linux platform, it is not surprising to see the differences like that. So what's the version of your Linux platform? Have you checked it based on System Requirements? Or you could try the previous version of odbc driver and see if it works.

    Reference

    System Requirements

    If all methods have been used up, you could submit your issue to https://feedback.azure.com/forums/908035-sql-server for help.  At the same time, I find a related thread which is talking about SQLCancel() function, hope this could be useful to you.

    Best Regards,

    Will


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 22, 2019 8:30 AM
    Moderator
  • Thanks Dan Guzman , yes that's right. our CPP code link with MSSQL ODBC driver and try to work on both Windows and Linux, but so far for the exact same ODBC API function, the behavior between Windows and Linux are difference, that why really confused us

    Hi oldhawkcn,

    Thanks for your reply.

    MSSQL ODBC driver on Windows platform is more mature than one on Linux platform, it is not surprising to see the differences like that. So what's the version of your Linux platform? Have you checked it based on System Requirements? Or you could try the previous version of odbc driver and see if it works.

    Reference

    System Requirements

    If all methods have been used up, you could submit your issue to https://feedback.azure.com/forums/908035-sql-server for help.  At the same time, I find a related thread which is talking about SQLCancel() function, hope this could be useful to you.

    Best Regards,

    Will


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Hi Will, we use latest 17.3 Linux ODBC driver and on SUSE12 SP2 platform.  This behavior difference cause we stopped port our current code from Windows to Linux. if you can find any relative discussion please let me know thanks.
    Monday, July 22, 2019 12:16 PM
  • Hi Will, we use latest 17.3 Linux ODBC driver and on SUSE12 SP2 platform.  This behavior difference cause we stopped port our current code from Windows to Linux. if you can find any relative discussion please let me know thanks.

    Hi oldhawkcn,

    I apologize for my mistake. I forget to upload the link for the related thread.

    SQL Server ODBC for Linux: Support query interruption with SQLCancel()

    In my opinion, you need to submit this issue to feedback website, so that you would get exact response at specific time. Due to that Linux has so many kinds of product with different versions, and the chances of encountering the same issue is slim, therefore, it is beyond of support range and you need to ask develop team of Microsoft for further check.

    Best Regards,

    Will


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 24, 2019 9:02 AM
    Moderator