Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
padiga-isw
Frequent Visitor

Power BI fails to send query termination requests to ODBC driver during cancellation operation

Hi Team,
When canceling data refresh operations in Power BI or switching between tables in the Transform Data tab, Power BI does not properly send query termination requests to the Trino ODBC driver. This results in incomplete cleanup of database connections and potential resource leaks.
I am using Power BI Desktop with Simba Trino Driver, and capturing the Driver Manager Trace logs through ODBC Data Source.

So when I captured the Driver Manager logs, these are the last few lines after I cancelled the query while refreshing or in Transform data tab:

Microsoft.Mashu a654-4c80	ENTER SQLGetInfoW 
        HDBC                0x000002200FD0D930
        UWORD                        6 <SQL_DRIVER_NAME>
        PTR                 0x0000022012AD1F10 
        SWORD                      100 
        SWORD *             0x0000008B33BFD45C

Microsoft.Mashu a654-4c80	EXIT  SQLGetInfoW  with return code 0 (SQL_SUCCESS)
        HDBC                0x000002200FD0D930
        UWORD                        6 <SQL_DRIVER_NAME>
        PTR                 0x0000022012AD1F10 [      36] "TrinoODBC_sb64.dll"
        SWORD                      100 
        SWORD *             0x0000008B33BFD45C (36)

Microsoft.Mashu 9104-953c	ENTER SQLPrepareW 
        HSTMT               0x000001925780DEF0
        WCHAR *             0x0000019259B5D53C [      -3] "select * from tpch.sf1000.orders LIMIT 10000\ 0"
        SDWORD                    -3

Microsoft.Mashu a654-4c80	ENTER SQLPrepareW 
        HSTMT               0x000002200FD0DEF0
        WCHAR *             0x0000022011F5DBAC [      -3] "select * from tpch.sf1000.orders LIMIT 50000\ 0"
        SDWORD                    -3
Microsoft.Mashu b520-62b0	EXIT  SQLGetData  with return code 0 (SQL_SUCCESS)
        HSTMT               0x00000211E16AE070
        UWORD                        3 
        SWORD                       -8 <SQL_C_WCHAR>
        PTR                 0x00000211E4024EE0 [       2] "F"
        SQLLEN                  2048
        SQLLEN *            0x000000CE84FFDB88 (2)

Microsoft.Mashu b520-62b0	ENTER SQLGetData 
        HSTMT               0x00000211E16AE070
        UWORD                        4 
        SWORD                        8 <SQL_C_DOUBLE>
        PTR                 <unknown type>
        SQLLEN                  2048
        SQLLEN *            0x000000CE84FFDB88

Microsoft.Mashu b520-62b0	EXIT  SQLGetData  with return code 0 (SQL_SUCCESS)
        HSTMT               0x00000211E16AE070
        UWORD                        4 
        SWORD                        8 <SQL_C_DOUBLE>
        PTR                 <unknown type>
        SQLLEN                  2048
        SQLLEN *            0x000000CE84FFDB88 (8)

Microsoft.Mashu b520-62b0	ENTER SQLGetData 
        HSTMT               0x00000211E16AE070
        UWORD                        5 
        SWORD                       91 <SQL_C_TYPE_DATE>
        PTR                 <unknown type>
        SQLLEN                  2048
        SQLLEN *            0x000000CE84FFDB88

Microsoft.Mashu b520-62b0	EXIT  SQLGetData  with return code 0 (SQL_SUCCESS)
        HSTMT               0x00000211E16AE070
        UWORD                        5 
        SWORD                       91 <SQL_C_TYPE_DATE>
        PTR                 <unknown type>
        SQLLEN                  2048
        SQLLEN *            0x000000CE84FFDB88 (6)


When I check for query terminations that Power BI does while fetching native query, it terminates using SQLFreeHandle/SQLDisconnect for schema discovery, validation and preview.

Microsoft.Mashu 7738-8f38	ENTER SQLMoreResults 
        HSTMT               0x000002BFC05EE240

Microsoft.Mashu 7738-8f38	EXIT  SQLMoreResults  with return code 100 (SQL_NO_DATA_FOUND)
        HSTMT               0x000002BFC05EE240

Microsoft.Mashu 7738-8f38	ENTER SQLFreeHandle 
        SQLSMALLINT                  3 <SQL_HANDLE_STMT>
        SQLHANDLE           0x000002BFC05EE240

Microsoft.Mashu 7738-8f38	EXIT  SQLFreeHandle  with return code 0 (SQL_SUCCESS)
        SQLSMALLINT                  3 <SQL_HANDLE_STMT>
        SQLHANDLE           0x000002BFC05EE240
Microsoft.Mashu 7738-3540	ENTER SQLDisconnect 
		HDBC                0x000002BFC05EDC80

Microsoft.Mashu 7738-3540	EXIT  SQLDisconnect  with return code 0 (SQL_SUCCESS)
		HDBC                0x000002BFC05EDC80

Microsoft.Mashu 7738-3540	ENTER SQLFreeHandle 
		SQLSMALLINT                  2 <SQL_HANDLE_DBC>
		SQLHANDLE           0x000002BFC05EDC80

Microsoft.Mashu 7738-3540	EXIT  SQLFreeHandle  with return code 0 (SQL_SUCCESS)
		SQLSMALLINT                  2 <SQL_HANDLE_DBC>
		SQLHANDLE           0x000002BFC05EDC80


But this behaviour is not seen during Refresh Cancellation/Transform Data tab. Is this an expected behaviour? if so how should the driver know that the Power BI is no longer accessing the query? Is there any solution/workaround for this, so that Power BI sends a request to the driver that the request can be terminated?
I couldn't find this in known issues: https://support.fabric.microsoft.com/known-issues/?product=Power%2520BI

Thanks

1 ACCEPTED SOLUTION
Zanqueta
Super User
Super User

Hi @padiga-isw , this is expected behaviour. Power BI does not guarantee sending SQLCancel during cancellation. The best approach is to configure timeouts or resource management at the driver or Trino level.

 

Possible Workarounds

  1. Driver-Level Timeout
    Configure query timeout in the ODBC DSN or driver settings (e.g., QueryTimeout parameter). This ensures long-running queries terminate automatically if Power BI abandons them.
  2. Connection Pooling Disabled
    Disable pooling so that when Power BI frees the handle, the connection is truly closed, releasing resources.
  3. Monitor and Kill Queries at Source
    If using Trino, configure resource groups or query kill policies on the server side to handle abandoned queries.

 

If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

View solution in original post

1 REPLY 1
Zanqueta
Super User
Super User

Hi @padiga-isw , this is expected behaviour. Power BI does not guarantee sending SQLCancel during cancellation. The best approach is to configure timeouts or resource management at the driver or Trino level.

 

Possible Workarounds

  1. Driver-Level Timeout
    Configure query timeout in the ODBC DSN or driver settings (e.g., QueryTimeout parameter). This ensures long-running queries terminate automatically if Power BI abandons them.
  2. Connection Pooling Disabled
    Disable pooling so that when Power BI frees the handle, the connection is truly closed, releasing resources.
  3. Monitor and Kill Queries at Source
    If using Trino, configure resource groups or query kill policies on the server side to handle abandoned queries.

 

If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors