Conversation
370cb81 to
beb33bd
Compare
CharlieTLe
left a comment
There was a problem hiding this comment.
The V2 pool was introduced in 918aa41 and shipped in v1.20.0, so the missing symbol clearing is a bug in a released version. Should a [BUGFIX] CHANGELOG entry be added?
pkg/cortexpb/timeseriesv2_test.go
Outdated
| assert.Equal(t, "", underlyingArray[1]) | ||
| } |
There was a problem hiding this comment.
Three symbols are appended ("", "name", "test") but only indices 0 and 1 are checked. Should index 2 be asserted as well?
| assert.Equal(t, "", underlyingArray[1]) | |
| } | |
| assert.Equal(t, "", underlyingArray[1]) | |
| assert.Equal(t, "", underlyingArray[2]) | |
| } |
| }) | ||
| } | ||
|
|
||
| func TestReuseWriteRequestV2(t *testing.T) { |
There was a problem hiding this comment.
Could this test flake since sync.Pool doesn't guarantee Get returns the same object that was just Put? If the GC runs between the ReuseWriteRequestV2 and PreallocWriteRequestV2FromPool calls, a fresh object would be returned and the backing array assertions would be skipped.
Would it be more robust to capture a reference to the backing array before the reuse call, so the clearing can be verified directly without depending on the pool?
// Capture backing array before reuse
backingArray := req.Symbols[:cap(req.Symbols)]
ReuseWriteRequestV2(req)
// Verify clearing directly on the backing array
for i, s := range backingArray[:3] {
assert.Equalf(t, "", s, "symbol at index %d not cleared", i)
}There was a problem hiding this comment.
I fixed it at the latest commit to check if the symbol table is reset without GC.
Thanks for the comment!
fdb24ce to
f263b6c
Compare
46b99d9 to
c2a3c20
Compare
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
c2a3c20 to
d3ad749
Compare
This PR improves V2 write request memory pooling by preventing string pointer leaks, adding explicit string clearing in
ReuseWriteRequestV2to prevent memory leaks when reusing pooled requests, and removing redundant exemplar label cleanup fromReuseTimeseriesV2.Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]