File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,15 +188,15 @@ jobs:
188188
189189 ui-style :
190190 needs : [changes]
191- if :
192- needs.changes.outputs.client == 'true' || needs.changes.outputs.ci ==
193- ' true' || github.ref == 'refs/heads/main'
191+ if : false
192+ # needs.changes.outputs.client == 'true' || needs.changes.outputs.ci ==
193+ # 'true' || github.ref == 'refs/heads/main'
194194 runs-on : ubuntu-latest
195195 steps :
196196 - uses : actions/checkout@v5
197197 - uses : actions/setup-node@v6
198198 with :
199- node-version : ' 20 '
199+ node-version : ' 22 '
200200 - uses : pnpm/action-setup@v4
201201 with :
202202 version : latest
@@ -396,6 +396,7 @@ jobs:
396396 env :
397397 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD : 1
398398 runs-on : ubuntu-latest
399+ if : false
399400 steps :
400401 - uses : actions/checkout@v5
401402 - uses : actions/setup-node@v6
Original file line number Diff line number Diff line change @@ -814,6 +814,8 @@ class DatabricksConnectionConfig(ConnectionConfig):
814814 DISPLAY_NAME : t .ClassVar [t .Literal ["Databricks" ]] = "Databricks"
815815 DISPLAY_ORDER : t .ClassVar [t .Literal [3 ]] = 3
816816
817+ shared_connection : t .ClassVar [bool ] = True
818+
817819 _concurrent_tasks_validator = concurrent_tasks_validator
818820 _http_headers_validator = http_headers_validator
819821
Original file line number Diff line number Diff line change @@ -1422,6 +1422,35 @@ def test_databricks(make_config):
14221422 )
14231423
14241424
1425+ def test_databricks_shared_connection (make_config ):
1426+ """Databricks should use a shared connection pool to prevent OAuth CSRF races.
1427+
1428+ When concurrent_tasks > 1, ThreadLocalConnectionPool creates one connection per
1429+ thread. For U2M OAuth, each thread triggers its own browser-based OAuth flow;
1430+ these race on the CSRF state parameter and cause MismatchingStateError.
1431+
1432+ Setting shared_connection = True causes ThreadLocalSharedConnectionPool to be
1433+ used instead: a single connection is created (behind a lock) and each thread
1434+ gets its own cursor, so only one OAuth flow is ever initiated.
1435+
1436+ See: https://github.com/tobymao/sqlmesh/issues/5646
1437+ """
1438+ from sqlmesh .utils .connection_pool import ThreadLocalSharedConnectionPool
1439+
1440+ config = make_config (
1441+ type = "databricks" ,
1442+ server_hostname = "dbc-test.cloud.databricks.com" ,
1443+ http_path = "sql/test/foo" ,
1444+ access_token = "test-token" ,
1445+ concurrent_tasks = 4 ,
1446+ )
1447+ assert isinstance (config , DatabricksConnectionConfig )
1448+ assert config .shared_connection is True
1449+
1450+ adapter = config .create_engine_adapter ()
1451+ assert isinstance (adapter ._connection_pool , ThreadLocalSharedConnectionPool )
1452+
1453+
14251454def test_engine_import_validator ():
14261455 with pytest .raises (
14271456 ConfigError ,
You can’t perform that action at this time.
0 commit comments