Skip to content

[vParquet5] Fix buffer reuse bug with event-level dedicated columns#6914

Merged
mdisibio merged 6 commits intografana:mainfrom
mdisibio:vp5-event-buffer-reuse-fix
Apr 10, 2026
Merged

[vParquet5] Fix buffer reuse bug with event-level dedicated columns#6914
mdisibio merged 6 commits intografana:mainfrom
mdisibio:vp5-event-buffer-reuse-fix

Conversation

@mdisibio
Copy link
Copy Markdown
Contributor

@mdisibio mdisibio commented Apr 9, 2026

What this PR does:
There is a bug with buffer reuse in event-level dedicated columns, for event attributes. The buffer was not sufficiently cleared, leading to duplicated attributes across events.

Extended the roundtrip/tempodb level tests to fully populate all options and types now (like integers and blobs), to test holistically, and not just in the encoding itself. Verified they exhibit the bug before fixing.

I updated vulture with more randomness too, but it wasn't able to trigger the bug. I think it requires a higher write volume.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extends Tempodb/vParquet round-trip and query tests to better reproduce and prevent a buffer reuse bug affecting event-level dedicated columns (especially for blob/int dedicated attributes).

Changes:

  • Add dedicated column assignments to tempodb round-trip tests and populate traces with random dedicated attributes (including event-level).
  • Update vParquet3/4/5 tests to treat dedicated.span.5 as a blob-backed string and use a consistent fixed blob payload for assertions.
  • Add utilities in pkg/util/test to generate dedicated attributes (including blob-sized payloads).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tempodb/tempodb_test.go Configures blocks with dedicated columns and enriches traces with dedicated attributes for end-to-end round-trip verification.
tempodb/encoding/vparquet5/schema_test.go Updates expected dedicated attribute values to use the blob test payload.
tempodb/encoding/vparquet5/block_traceql_test.go Updates TraceQL match cases for blob-backed dedicated span attribute.
tempodb/encoding/vparquet5/block_search_test.go Updates search tests to use blob payload for dedicated span attribute.
tempodb/encoding/vparquet5/block_findtracebyid_test.go Strengthens find-by-id test to round-trip fully populated traces and explicitly exercises buffer reuse.
tempodb/encoding/vparquet4/schema_test.go Aligns vParquet4 schema tests with blob payload expectations for dedicated.span.5.
tempodb/encoding/vparquet4/block_traceql_test.go Aligns vParquet4 TraceQL tests with blob payload expectations.
tempodb/encoding/vparquet4/block_search_test.go Aligns vParquet4 search tests with blob payload expectations.
tempodb/encoding/vparquet3/schema_test.go Aligns vParquet3 schema tests with blob payload expectations.
tempodb/encoding/vparquet3/block_traceql_test.go Aligns vParquet3 TraceQL tests with blob payload expectations.
tempodb/encoding/vparquet3/block_search_test.go Aligns vParquet3 search tests with blob payload expectations.
pkg/util/trace_info.go Modifies vulture trace tag generation (randomizes presence of some “fixed” tags and well-known attributes).
pkg/util/test/req.go Adds helpers/constants for dedicated column generation, including blob-sized payloads and random dedicated attribute population.

Comment thread pkg/util/test/req.go Outdated
Comment thread pkg/util/trace_info.go Outdated
Comment thread pkg/util/trace_info.go Outdated
Copilot AI review requested due to automatic review settings April 9, 2026 21:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread CHANGELOG.md Outdated
Comment thread tempodb/tempodb_test.go
Comment on lines +606 to +613
var (
id = test.ValidTraceID(nil)
req = test.MakeTrace(rand.Int()%10, id)
)

// Populate data using the same dedicated columns as configured on the block above.
test.AddRandomDedicatedAttributes(req)

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

These tests now rely on randomized dedicated attributes (including per-event subsets) to reproduce the buffer-reuse bug. Because TestCompleteBlock runs many subtests with t.Parallel() and uses the global math/rand, the exact attribute patterns can vary with scheduling, which can make this regression test less deterministic (e.g., in the unlikely case all events happen to set all dedicated columns). What do you think about making the pattern deterministic (fixed seed/local rand, or explicitly constructing at least one event where a dedicated column is omitted) so the bug is guaranteed to be exercised?

Copilot generated this review using guidance from repository custom instructions.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately I don't think this will work. A static seed that triggers the bug now, could easily stop triggering the bug after innocuous changes and go unnoticed. The randomness has been serving us well for several years, we'll keep it for now.

Comment thread tempodb/tempodb_test.go Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 9, 2026 21:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comment thread tempodb/tempodb_test.go
Comment thread pkg/util/trace_info.go
Comment on lines 226 to +233
// generateFixedAttributesWithPrefix returns the fixed attributes with a prefix. Keys are lowercase with a hyphen before the numeric suffix (e.g. string-01, int-01, blob-01).
func (t *TraceInfo) generateFixedAttributesWithPrefix(prefix string) []*jaeger.Tag {
return []*jaeger.Tag{
{Key: fmt.Sprintf("%s-string-01", prefix), VType: jaeger.TagType_STRING, VStr: stringPtr(t.generateRandomString())},
{Key: fmt.Sprintf("%s-string-02", prefix), VType: jaeger.TagType_STRING, VStr: stringPtr(t.generateRandomString())},
{Key: fmt.Sprintf("%s-string-03", prefix), VType: jaeger.TagType_STRING, VStr: stringPtr(t.generateRandomString())},
{Key: fmt.Sprintf("%s-string-04", prefix), VType: jaeger.TagType_STRING, VStr: stringPtr(t.generateRandomString())},
{Key: fmt.Sprintf("%s-string-05", prefix), VType: jaeger.TagType_STRING, VStr: stringPtr(t.generateRandomString())},
{Key: fmt.Sprintf("%s-blob-01", prefix), VType: jaeger.TagType_STRING, VStr: stringPtr(t.generateRandomBlob(vultureBlobSize))},
{Key: fmt.Sprintf("%s-int-01", prefix), VType: jaeger.TagType_LONG, VLong: int64Ptr(t.generateRandomInt(1, 1000000))},
{Key: fmt.Sprintf("%s-int-02", prefix), VType: jaeger.TagType_LONG, VLong: int64Ptr(t.generateRandomInt(1, 1000000))},
{Key: fmt.Sprintf("%s-int-03", prefix), VType: jaeger.TagType_LONG, VLong: int64Ptr(t.generateRandomInt(1, 1000000))},
{Key: fmt.Sprintf("%s-int-04", prefix), VType: jaeger.TagType_LONG, VLong: int64Ptr(t.generateRandomInt(1, 1000000))},
{Key: fmt.Sprintf("%s-int-05", prefix), VType: jaeger.TagType_LONG, VLong: int64Ptr(t.generateRandomInt(1, 1000000))},
var (
numStrings = t.r.Intn(6)
numBlobs = t.r.Intn(2)
numInts = t.r.Intn(6)
tags = make([]*jaeger.Tag, 0, numStrings+numBlobs+numInts)
)
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

generateFixedAttributesWithPrefix (and its comment) now returns a random count of tags with random values, so it’s no longer “fixed”. This is confusing for callers/readers and makes the docstring inaccurate. Could we either rename the helper (and/or update the comment) to reflect the new randomized behavior?

Copilot uses AI. Check for mistakes.
@mdisibio mdisibio marked this pull request as ready for review April 9, 2026 22:07
@mdisibio mdisibio changed the title WIP: [vParquet5] Fix buffer reuse bug with event-level dedicated columns [vParquet5] Fix buffer reuse bug with event-level dedicated columns Apr 10, 2026
@mdisibio mdisibio merged commit 14d0452 into grafana:main Apr 10, 2026
27 checks passed
javiermolinar pushed a commit that referenced this pull request Apr 11, 2026
…6914)

* Add failing tests at multiple levels that trigger the bug

* Update tests, lint, and fix vp5 actual bug

* review feedback

* changelog

* Update CHANGELOG.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tempodb/tempodb_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

4 participants