Repository navigation
[client-v2] Measure only the row writing in OP_SERIALIZATION - #3463
Open
kushagra0526 wants to merge 1 commit into
Open
kushagra0526 wants to merge 1 commit into
kushagra0526 wants to merge 1 commit into
Conversation
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.
Summary
Fixes #3198.
For a POJO insert,
OP_SERIALIZATIONstarted together withOP_DURATIONand was only stopped byoperationComplete(), after the response arrived. The two metrics were always equal, andclickhouse.client.operation.serialization.durationreported network and server time as serialization.The stopwatch is now started at the top of the request body writer and stopped after the rows are written, so a retried insert reports the last attempt.
operationComplete()stops every watch again, so the writer also calls a newStopWatch.freeze()to keep this value. OnlyOP_SERIALIZATIONis frozen;stop()behaves as before for every other watch.The measured time still includes any blocking on the socket while the body is streamed.
Test:
testInsertSerializationDurationExcludesWaitingForTheServerdelays the mock server by 2 s. On main it reports 2.02 s of serialization; with the change it is under 1 s. The client-v2*UnitTestclasses pass (112 tests).Closes #3198
Compatibility
No public API change.
clickhouse.client.operation.serialization.durationnow reports only the time spent writing rows for POJO inserts, so dashboards will show much smaller values than before (previously it equalled the full operation duration).Testing
Insert*Tests) pass locally on ClickHouse 26.11.5.8 (126 run, 0 failures, 0 skipped). No new integration test added.Checklist
Note
Low Risk
Observability-only timing change with localized StopWatch behavior; no insert protocol or auth changes.
Overview
Fixes misleading serialization duration on POJO inserts:
OP_SERIALIZATIONno longer starts withOP_DURATIONat operation begin. It is started and stopped inside the HTTP request body callback, covering only writing theINSERTheader and row binary for the POJOs.Because each retry rewrites the body, the metric reflects the last attempt's write time.
StopWatchgainsfreeze()sooperationComplete()'s laterstop()does not overwrite that value.A WireMock test asserts
OPERATION_SERIALIZATION_DURATIONstays under 1s while the server adds a 2s delay, proving network/server wait is not counted as serialization (though time blocked on the socket while streaming the body still is).Reviewed by Cursor Bugbot for commit 8e711cf. Bugbot is set up for automated code reviews on this repo. Configure here.