Skip to content

[BUG]: Data race issue with span #3270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jachym-tousek-keboola opened this issue Mar 7, 2025 · 1 comment · May be fixed by #3278
Open

[BUG]: Data race issue with span #3270

jachym-tousek-keboola opened this issue Mar 7, 2025 · 1 comment · May be fixed by #3278
Assignees
Labels
bug unintended behavior that has to be fixed tracer

Comments

@jachym-tousek-keboola
Copy link

Tracer Version(s)

1.72.1

Go Version(s)

1.24.0

Bug Report

Lately we're seeing data race errors in our logs.

Read:

labels = append(labels, traceprof.TraceEndpoint, localRootSpan.Resource)

Image

Write:

s.Resource = v

Image

The write side seems to have a lock from here:

s.Lock()
defer s.Unlock()

My guess is that applyPPROFLabels is missing localRootSpan.RLock()? Should I send a pull request that would add it?

Reproduction Code

No response

Error Logs

No response

Go Env Output

No response

@jachym-tousek-keboola jachym-tousek-keboola added the bug unintended behavior that has to be fixed label Mar 7, 2025
@github-actions github-actions bot added the needs-triage New issues that have not yet been triaged label Mar 7, 2025
@nsrip-dd
Copy link
Contributor

nsrip-dd commented Mar 7, 2025

Thanks for reporting this issue! I can reproduce this with this test:

func TestPPROFLabelRootSpanRace(t *testing.T) {
	tracer, _, _, stop := startTestTracer(t)
	defer stop()
	parent := tracer.StartSpan("parent")
	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		defer wg.Done()
		for i := 0; i < 1000; i++ {
			tracer.StartSpan("child", ChildOf(parent.Context()))
		}
	}()
	wg.Add(1)
	go func() {
		defer wg.Done()
		for i := 0; i < 1000; i++ {
			parent.SetTag(ext.ResourceName, "x")
		}
	}()
	wg.Wait()
}

Taking a read lock on the parent span makes sense to me as a fix. Please feel free to send a PR :)

@nsrip-dd nsrip-dd added tracer and removed needs-triage New issues that have not yet been triaged labels Mar 7, 2025
@jachym-tousek-keboola jachym-tousek-keboola linked a pull request Mar 10, 2025 that will close this issue
7 tasks
@darccio darccio self-assigned this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unintended behavior that has to be fixed tracer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants