Repository navigation
Conversation
…arehouse _drop_catalog only checked the calling thread's catalog state before deciding whether to close connections. Another thread could still target, or hold a connection on, the dropped warehouse, and Fabric rejects a connection to a missing warehouse with an authentication error (18456). Check every thread's target and connected catalog, and log which state matched and which warehouse a failed connection targeted. Signed-off-by: mday-io <mdaytn@gmail.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Description
Why
engine-tests-cloud (fabric)fails on everymainrun intest_janitor[fabric-catalog]. The janitor deletes the dev warehouse, for exampleci_728e0c04__dev. The nextDROP TABLEin the prod warehouse then fails to connect:Could not login because the authentication failed. (18456) (SQLDriverConnect). Fabric returns that error when a connection'sDATABASE=names a warehouse that doesn't exist.The Fabric adapter keeps each thread's catalog in two thread-local attributes on the connection pool:
target_catalogandconnected_catalog._drop_catalogclosed connections only when the calling thread referenced the dropped warehouse. Other threads were not checked. A worker thread that switched to the dev warehouse during plan promotion could still target it or hold a connection on it after the warehouse was deleted. So could a new thread that reuses a finished thread's ident and inherits its pool state.How
_drop_catalognow checks thetarget_catalogandconnected_catalogof every thread withget_all_attributes. It also checks the calling thread's resolved catalog, because a thread with no attributes yet still resolves to the default warehouse. If any of these name the dropped warehouse, it closes all connections, which also clears every thread's catalog state. When nothing references the warehouse, it leaves connections alone, as before.get_all_attributesiterates without a lock, so a thread that starts at the same moment can raiseRuntimeError. In that case the adapter closes all connections.mainrun:This removes the stale-state cause. I haven't confirmed that it explains the CI failure. If Fabric itself briefly rejects logins after a warehouse is deleted, the job will keep failing. The new logs will then show that the failed connection targeted an existing warehouse.
Test Plan
tests/core/engine_adapter/test_fabric.py. Each one uses real threads on a thread-local pool:get_all_attributesraises, so connections are closedfabric.pyreverted tomain, 5 of the new tests fail and 2 pass. The 2 that pass are the negative control and a check thatmainalready covered. With the fix,pytest tests/core/engine_adapter/test_fabric.py tests/utils/test_connection_pool.pypasses: 48 passed.ruff check,ruff format --checkandmypypass on the changed files.make fast-testran in a local venv that is missing optional packages (pyodbc,agate,pyspark,PyGithub). Its failures are import errors, and the Fabric connection-config tests fail the same way onmain. I'm relying on CI for the full fast-test run.main, so the Fabric integration test runs after merge.Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCOSummary by CodeRabbit