Repository navigation
[PECOBLR-1830] Cache connectionContext to avoid log pollution from getConnection() - #1210
vikrantpuppala wants to merge 4 commits into
Conversation
…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]>
There was a problem hiding this comment.
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
IDatabricksConnectionContextinDatabricksResultSetconstructors that have anIDatabricksSession. - Update
next()to callTelemetryHelper.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.
This comment was marked as resolved.
Sorry, something went wrong.
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]>
| @@ -209,6 +214,7 @@ public DatabricksResultSet( | |||
| this.statementType = statementType; | |||
| this.updateCount = null; | |||
| this.parentStatement = null; | |||
There was a problem hiding this comment.
this is not test scenario, why can't we provide context here?
There was a problem hiding this comment.
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
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Vikrant Puppala <[email protected]>
|
Closing this in favour of #1223 which already solved the core problem by caching |
## 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]>
Summary
TelemetryHelper#recordResultSetIterationwas callingparentStatement.getStatement().getConnection()on everyResultSet.next()call, causing excessive debug log noise and unnecessary overheadconnectionContextatDatabricksResultSetconstruction time and call the directrecordResultSetIteration(connectionContext, ...)overload insteadgetConnection()log entriesNO_CHANGELOG=true
Test plan
DatabricksResultSetTest: 43 tests,TelemetryHelperTest: 74 tests)getConnection()log pollution during row iteration🤖 Generated with Claude Code