Skip to content

reapply: "fix: refactor coder logger to allow flush without deadlock (#375)" #377

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

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

mafredri
Copy link
Member

dac, err := initRPC(ctx, client, metaLogger.Named("init_rpc"))
if err != nil {
// Logged externally
return nil, nil, fmt.Errorf("init coder rpc client: %w", err)
}
ls := agentsdk.NewLogSender(metaLogger.Named("coder_log_sender"))
metaLogger.Warn(ctx, "Sending logs via AgentAPI v2", slog.F("coder_version", bi.Version))
sendLogs, doneFunc := sendLogsV2(ctx, dac, ls, metaLogger.Named("send_logs_v2"))
return sendLogs, doneFunc, nil
logger, loggerCloser := sendLogsV2(ctx, dac, ls, metaLogger.Named("send_logs_v2"))
Copy link
Member Author

Choose a reason for hiding this comment

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

Review: This used to be called closer, i.e. return variable name. After a last minute change in #375 we wrapped this function to ensure we can close drpcconn as well. This resulted in the variable being reassigned and calling itself.

 goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc048806380 stack=[0xc048806000, 0xc068806000]
fatal error: stack overflow

runtime stack:
runtime.throw({0x2088d94?, 0x200000001?})
	/usr/local/go/src/runtime/panic.go:1023 +0x5c fp=0x7ffdb0730768 sp=0x7ffdb0730738 pc=0x43e05c
runtime.newstack()
	/usr/local/go/src/runtime/stack.go:1103 +0x5bd fp=0x7ffdb0730918 sp=0x7ffdb0730768 pc=0x45a77d
runtime.morestack()
	/usr/local/go/src/runtime/asm_amd64.s:616 +0x7a fp=0x7ffdb0730920 sp=0x7ffdb0730918 pc=0x477b3a

if err != nil {
cancel()
}
}()
Copy link
Member Author

Choose a reason for hiding this comment

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

Review: This is a cautious addition to ensure there's no internal logic in client.ConnectRPC20(ctx) that might block or leave the connection open. This is to make it safer to call drpcconn close later.

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

unblocking 👍

@mafredri mafredri merged commit b3d1ec8 into main Sep 30, 2024
4 checks passed
@mafredri mafredri deleted the mafredri/logssss-unrevert branch September 30, 2024 17:06
mafredri added a commit that referenced this pull request Oct 2, 2024
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.

2 participants