Skip to content
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

Event Batch Mode Panic #951

Closed
ctriv opened this issue Nov 9, 2022 · 1 comment
Closed

Event Batch Mode Panic #951

ctriv opened this issue Nov 9, 2022 · 1 comment

Comments

@ctriv
Copy link

ctriv commented Nov 9, 2022

Description

If Events.BatchMode() is used with a context that finishing (ie, the Done() channel produces a message), there is a panic in a trace log line

Go Version

go version go1.19.3 darwin/arm64

Current behavior

Entered batch mode using a cancelable context. When the context is canceled, a panic is issued.

Expected behavior

The library should finish cleanly when the context is done.

Steps To Reproduce

  1. Enter batch mode with a cancelable context:
ctx, done := context.WithCancel(context.Background())
client.BatchMode(ctx, 123456, ....)
  1. do work, send events, etc..
client.EnqueueEvent(ctx, ....)
  1. Call done to cancel the context:
done()
  1. Panic

goroutine 33 [running]:
github.com/newrelic/newrelic-client-go/v2/pkg/logging.createFieldMap(...)
	/Users/creinhardt/go/pkg/mod/github.com/newrelic/newrelic-client-go/[email protected]/pkg/logging/logrus_logger.go:101
github.com/newrelic/newrelic-client-go/v2/pkg/logging.LogrusLogger.Trace({0x14000064e78?}, {0x1011c8a72?, 0xc?}, {0x1400055e040?, 0x140006e4201?, 0x0?})
	/Users/creinhardt/go/pkg/mod/github.com/newrelic/newrelic-client-go/[email protected]/pkg/logging/logrus_logger.go:92 +0x1d8
github.com/newrelic/newrelic-client-go/v2/pkg/events.(*Events).batchWorker(0x10191fba0, {0x10143a878, 0x1400009ae80}, 0x0)
	/Users/creinhardt/go/pkg/mod/github.com/newrelic/newrelic-client-go/[email protected]/pkg/events/events_batch.go:170 +0x314
github.com/newrelic/newrelic-client-go/v2/pkg/events.(*Events).BatchMode.func2(0x14000243400?)
	/Users/creinhardt/go/pkg/mod/github.com/newrelic/newrelic-client-go/[email protected]/pkg/events/events_batch.go:44 +0x34
created by github.com/newrelic/newrelic-client-go/v2/pkg/events.(*Events).BatchMode
	/Users/creinhardt/go/pkg/mod/github.com/newrelic/newrelic-client-go/[email protected]/pkg/events/events_batch.go:43 +0x230

Additional Context

The line in question is a trace logging line:
e.logger.Trace("batchWorker[", id, "]: exiting per context Done")
Probably just need to change that to
e.logger.Trace(fmt.Sprintf("batchWorker[%d]: exiting per context Done", id))

@pranav-new-relic
Copy link
Member

@ctriv I believe this should no longer be an issue, given these changes (#1104) which were recently merged to address the exact same issue. Closing the issue - thank you for reporting.

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

No branches or pull requests

2 participants