Skip to content

[PECOBLR-1830] Cache connectionContext to avoid log pollution from getConnection() - #1210

Closed
vikrantpuppala wants to merge 4 commits into
mainfrom
pecoblr-1830-fix-v2
Closed

vikrantpuppala wants to merge 4 commits into
mainfrom
pecoblr-1830-fix-v2

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

Summary

  • TelemetryHelper#recordResultSetIteration was calling parentStatement.getStatement().getConnection() on every ResultSet.next() call, causing excessive debug log noise and unnecessary overhead
  • Cache the connectionContext at DatabricksResultSet construction time and call the direct recordResultSetIteration(connectionContext, ...) overload instead
  • Verified against dogfood: 1000-row iteration produces zero getConnection() log entries

NO_CHANGELOG=true

Test plan

  • Existing unit tests pass (DatabricksResultSetTest: 43 tests, TelemetryHelperTest: 74 tests)
  • Manual verification against dogfood with debug logging confirmed zero getConnection() log pollution during row iteration

🤖 Generated with Claude Code

…d repeated getConnection() calls

TelemetryHelper#recordResultSetIteration was calling
parentStatement.getStatement().getConnection() on every next() call,
causing excessive log noise and unnecessary overhead. Cache the
connectionContext at construction time and call the direct overload
of recordResultSetIteration instead.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
Copilot AI review requested due to automatic review settings February 13, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces per-row overhead and debug log noise during ResultSet.next() by avoiding repeated parentStatement.getStatement().getConnection() calls, instead caching the IDatabricksConnectionContext at DatabricksResultSet construction time and using the direct telemetry overload.

Changes:

  • Cache IDatabricksConnectionContext in DatabricksResultSet constructors that have an IDatabricksSession.
  • Update next() to call TelemetryHelper.recordResultSetIteration(connectionContext, ...) instead of the parent-statement-based overload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

TelemetryHelper.recordResultSetIteration(
parentStatement, statementId, resultSetMetaData.getChunkCount(), hasNext);
Long chunkCount = resultSetMetaData.getChunkCount();
if (connectionContext != null && chunkCount != null) {

This comment was marked as resolved.

vikrantpuppala and others added 2 commits February 13, 2026 16:17
Add parentStatement != null guard to match the prior gating behavior,
so metadata result sets (where parentStatement is null) don't start
emitting telemetry they didn't before.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
Move null-checking for connectionContext and chunkCount into the
TelemetryHelper.recordResultSetIteration overload that takes
connectionContext directly, and remove the now-unused parentStatement
overload that called getConnection() on every invocation.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>

@sreekanth-db sreekanth-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@@ -209,6 +214,7 @@ public DatabricksResultSet(
this.statementType = statementType;
this.updateCount = null;
this.parentStatement = null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is not test scenario, why can't we provide context here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

primarily because i did not want to increase the scope of telemetry in this PR. earlier parent statement was null so telemetry was not being captured in this case. cc: @samikshya-db

@samikshya-db samikshya-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks!

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Vikrant Puppala <[email protected]>
@vikrantpuppala

Copy link
Copy Markdown
Collaborator Author

Closing this in favour of #1223 which already solved the core problem by caching TelemetryCollector directly in DatabricksResultSet. The dead code removal of the unused TelemetryHelper.recordResultSetIteration overloads will be handled in a separate PR.

vikrantpuppala added a commit that referenced this pull request Feb 25, 2026
## Summary
- Removes two unused `TelemetryHelper.recordResultSetIteration`
overloads that became dead code after #1223 switched
`DatabricksResultSet.next()` to use `cachedTelemetryCollector` directly
- Removes the now-unused `DatabricksConnection` import
- Supersedes #1210

NO_CHANGELOG=true

## Test plan
- [x] `mvn compile` passes
- [ ] CI checks pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Vikrant Puppala <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
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.

5 participants