Skip to content

Conversation

@msrathore-db
Copy link
Contributor

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • Other

Description

Issue #729: Connection failures hang CICD jobs for 15+ minutes, cannot be cancelled

  • Telemetry forced on even with enable_telemetry=False
  • 900-second timeout causes long hangs
  • Blocking shutdown prevents process exit

Issue #731: Race condition causes AttributeError: 'NoneType' object has no attribute 'request'

  • Async telemetry executes after _http_client is garbage collected
  • No null check before calling pool_manager.request()

Changes

Issue #729 (3 fixes)

  1. Respect enable_telemetry parameter (telemetry_client.py:722-729, client.py:321)
    - Added parameter to connection_failure_log() with early return if disabled
    - Connection passes user's preference through
  2. Reduce timeout to 30s (telemetry_client.py:299)
    - Changed from 900s to 30s for faster failure
  3. Non-blocking shutdown (telemetry_client.py:707)
    - Changed executor.shutdown(wait=True) to wait=False

Issue #731 (3 fixes)

  1. Null-safety check (unified_http_client.py:296-298)
    - Check if pool_manager is None before calling .request()
    - Raise RequestError with clear message
  2. Add del cleanup (telemetry_client.py:439-451)
    - Close _http_client during garbage collection
    - Ensures eventual resource cleanup
  3. Document lifecycle (telemetry_client.py:430-435)
    - Added docstring explaining why _http_client isn't closed in close()
    - Import RequestError from databricks.sql.exc

Impact

  • Connection failures exit in <1s instead of 15+ minutes
  • CICD jobs no longer hang
  • No more race condition AttributeError
  • enable_telemetry=False now respected in all scenarios

Backward Compatibility

Fully backward compatible. No API changes, only behavior improvements.

Closes #729
Closes #731

How is this tested?

  • Unit tests
  • E2E Tests
  • Manually
  • N/A

Related Tickets & Documents

@github-actions
Copy link

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Copy link
Contributor

@samikshya-db samikshya-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Per reviewer feedback on PR #734:

1. Revert timeout from 30s back to 900s (line 299)
   - Reviewer noted that with wait=False, timeout is not critical
   - The async nature and wait=False handle the exit speed

2. Revert telemetry_enabled parameter back to True (line 734)
   - Reviewer noted this is redundant given the early return
   - If enable_telemetry=False, we return early (line 729)
   - Line 734 only executes when enable_telemetry=True
   - Therefore using the parameter here is unnecessary

These changes address the reviewer's valid technical concerns while
keeping the core fixes intact:
- wait=False for non-blocking shutdown (critical for Issue #729)
- Early return when enable_telemetry=False (critical for Issue #729)
- All Issue #731 fixes (null-safety, __del__, documentation)

Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Apply Black formatting to files modified in previous commits:
- src/databricks/sql/common/unified_http_client.py
- src/databricks/sql/telemetry/telemetry_client.py

Changes are purely cosmetic (quote style consistency).

Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
@msrathore-db msrathore-db changed the title Fix #729 and #731: Telemetry lifecycle management [PECOBLR-1735] Fix #729 and #731: Telemetry lifecycle management Feb 5, 2026
Add @pytest.mark.xdist_group to telemetry test classes to ensure they
run sequentially on the same worker when using pytest-xdist (-n auto).

Root cause: Tests marked @pytest.mark.serial were still being
parallelized in CI because pytest-xdist doesn't respect custom markers
by default. With host-level telemetry batching (PR #718), tests
running in parallel would share the same TelemetryClient and interfere
with each other's event counting, causing test_concurrent_queries_sends_telemetry
to see 88 events instead of the expected 60.

The xdist_group marker ensures all tests in the "serial_telemetry"
group run on the same worker sequentially, preventing state interference.

Signed-off-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Modified telemetry_setup_teardown fixtures to clean up
TelemetryClientFactory state both BEFORE and AFTER each test, not just
after. This prevents leftover state from previous tests (pending events,
active executors) from interfering with the current test.

Root cause: In CI with sequential execution on the same worker, if a
previous test left pending telemetry events in the executor, those
events could be captured by the next test's mock, causing inflated
event counts (88 instead of 60).

Now ensures complete isolation between tests by resetting all shared
state before each test starts.

Signed-off-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

The _flush_event threading.Event was never cleared after stopping the
flush thread, remaining in "set" state. This caused timing issues in
subsequent tests where the Event was already signaled, triggering
unexpected flush behavior and causing extra telemetry events to be
captured (88 instead of 60).

Now explicitly clear the _flush_event flag in both setup (before test)
and teardown (after test) to ensure clean state isolation between tests.

This explains why CI consistently got 88 events - the flush_event from
previous tests triggered additional flushes during test execution.

Signed-off-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

1. Created new workflow 'test-telemetry-only.yml' that runs only the
   failing telemetry test with -n auto, mimicking real CI but much faster

2. Added debug output to test showing:
   - Client-side captured events
   - Number of futures/batches
   - Number of server responses
   - Server-reported successful events

This will help identify why CI gets 88 events vs local 60 events.

Signed-off-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

The workflow was failing during poetry install due to missing krb5
system libraries needed for kerberos dependencies.

Signed-off-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Changes across multiple workflows:

1. integration.yml:
   - Add krb5 system dependency to telemetry job
   - Fixes: krb5-config command not found error during poetry install

2. code-coverage.yml:
   - Add krb5 system dependency
   - Split telemetry tests into separate step for isolation
   - Maintains coverage accumulation with --cov-append

3. publish-test.yml:
   - Add krb5 system dependency for consistent builds

4. test_concurrent_telemetry.py:
   - Remove debug print statements

5. Delete test-telemetry-only.yml:
   - Remove temporary debug workflow

All workflows now have proper telemetry test isolation and
required system dependencies for kerberos packages.

Signed-off-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Poetry 2.3.2 installation fails with Python 3.9:
  Installing Poetry (2.3.2): An error occurred.

Other workflows use Python 3.10 and work fine. Updating to match
ensures consistency and avoids Poetry installation issues.

Signed-off-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

…tests

- Remove --dist=loadgroup from non-telemetry job (only needed for telemetry)
- Remove test_telemetry_e2e.py from telemetry job (was skipped before)
- This should fix test_uc_volume_life_cycle failure caused by changed test distribution
…e tests

- Only run test_concurrent_telemetry.py in isolated telemetry step
- test_telemetry_e2e.py was excluded in original workflow, keep it excluded
- Always run poetry install (not just on cache miss)
- Ensures fresh install with system dependencies (krb5)
- Matches pattern used in integration.yml
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

…nditional

- Remove duplicate system dependencies step
- Restore cache conditional to match main branch
- Keep Python 3.10 (our change from 3.9)
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

- All serial tests are telemetry tests (test_concurrent_telemetry.py and test_telemetry_e2e.py)
- They're already run in the isolated telemetry step
- Running -m serial with --ignore on both files results in 0 tests (exit code 5)
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

@msrathore-db msrathore-db merged commit 61f8029 into main Feb 6, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sporadic 'NoneType' object has no attribute 'request' error from telemetry — usage question ERROR: Rapid fire connection error without exit

2 participants