fix: move livy session cleanup into dbt connection lifecycle#206
Closed
Copilot wants to merge 3 commits into
Closed
fix: move livy session cleanup into dbt connection lifecycle#206Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/microsoft/dbt-fabricspark/sessions/96ef8542-bef0-4371-b4b8-192bc25c03d6 Co-authored-by: mdrakiburrahman <46581776+mdrakiburrahman@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/dbt-fabricspark/sessions/96ef8542-bef0-4371-b4b8-192bc25c03d6 Co-authored-by: mdrakiburrahman <46581776+mdrakiburrahman@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Livy session cleanup to honor dbt's connection-manager lifecycle
fix: move livy session cleanup into dbt connection lifecycle
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Thank you for making change! Please fill this template for your pull request to improve quality of check-in message.
Tip
This repo uses Conventional Commit conventions - please try to rename your PR headline to match it.
Warning
Please ensure to read through this whole set of instructions, specially the
Testsection.Why this change is needed
Livy session cleanup was implemented via module-level
atexithandlers, bypassing dbt’s adapter connection lifecycle (open/close).That made cleanup execution non-observable to dbt and decoupled failure handling from normal adapter control flow.
Repro context: importing adapter modules registered process-exit cleanup handlers in both singleton and high-concurrency Livy paths, including a global HC active-session registry used only for
atexitcleanup.How
Lifecycle ownership moved to connection manager
FabricSparkConnectionManager.close()/cleanup_all()viamanager.disconnect().Out-of-band cleanup removed
atexit.register(...)cleanup from:singleton_livy.pyconcurrent_livy.py_active_sessionsstate used exclusively for process-exit cleanup.Behavioral intent
Test
Important: Non-Microsoft Employee contributors
If you are not a Microsoft employee with a
foo@microsoft.comemail, you will not be able to run CI as it runs in the@microsoft.comFabric Tenant where you do not have access.In order for your PR to be considered for review, you must attach a clear screenshot of the output of you running the following command successfully:
Here's an example of a successful run:
To keep the quality of the repo high, if you do not attach a screenshot of successful local testing, your PR will be promptly closed.
Microsoft Employee contributors
Your PR will be subjected to full regression suite via GitHub Action.
It's highly recommended to run the tests locally so your contributions are promptly merged rather than failing in CI.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
1.0.0.127.in-addr.arpa/opt/mssql/bin/sqlservr(dns block)api.fabric.microsoft.com/home/REDACTED/work/dbt-fabricspark/dbt-fabricspark/.venv/bin/pytest pytest tests/unit -vv(dns block)/home/REDACTED/work/dbt-fabricspark/dbt-fabricspark/.venv/bin/pytest pytest tests/unit -vv git conf�� it} --global 150e59783fe3f3304c4f938035e26f5ff2f52381c9b7e88ef47/log.json 4c4f938035e26f5ff2f52381c9b7e88ef47/81c35b081dec6a64bb9dd1071fc171165c6a1ba4abb99ea305abd42dc71f/var/run/docker/runtime-runc/moby(dns block)/home/REDACTED/work/dbt-fabricspark/dbt-fabricspark/.venv/bin/pytest pytest tests/unit -vv --detach --pid-file /run/containerd/io.containerd.runtime.v2.task/moby/82e1acda59d9c150e59783fe3f3304c4f938035e26f5ff2f52381c9b7e88ef47/7a9a7c3336ee730ea72bc2b2487f434ef57b1898f550741eefee7ddd5a07dbt-fabricspark:test:unit 82e1acda59d9c150e59783fe3f3304c4f938035e26f5ff2f52381c9b7e88ef47 150e59783fe3f3304c4f938035e26f5ff2f52381c9b7e88ef47/log.json(dns block)metadata.google.internal/opt/mssql/bin/sqlservr(dns block)settings-win.data.microsoft.com/opt/mssql/bin/sqlservr(dns block)vortex.data.microsoft.com/opt/mssql/bin/sqlservr(dns block)www.google-analytics.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/dbt-fabricspark/dbt-fabricspark/node_modules/.bin/nx run dbt-fabricspark:lint(dns block)/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node /home/REDACTED/work/dbt-fabricspark/dbt-fabricspark/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker /tmp/plugin5593-2-361.370401.sock /home/REDACTED/work/dbt-fabricspark/dbt-fabricspark/node_modules/nx/src/plugins/project-json/build-nodes/project-json(dns block)/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node /home/REDACTED/work/dbt-fabricspark/dbt-fabricspark/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker /tmp/plugin5593-1-358.056406.sock /home/REDACTED/work/dbt-fabricspark/dbt-fabricspark/node_modules/nx/src/plugins/package-json(dns block)If you need me to access, download, or install something from one of these locations, you can either: