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

server: background tasks incorrectly hang off the server start context #90550

Closed
knz opened this issue Oct 24, 2022 · 2 comments · Fixed by #90608
Closed

server: background tasks incorrectly hang off the server start context #90550

knz opened this issue Oct 24, 2022 · 2 comments · Fixed by #90608
Assignees
Labels
A-observability-inf C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@knz
Copy link
Contributor

knz commented Oct 24, 2022

(found while working on #90384)

During server startup, in (*Server).PreStart() we have 2 contexts of interest:

  • ctx is bound to the top-level CLI command, and is tracing the initialization of the server. It has a tracing span attached.
  • workersCtx is a background context with a few log tags but no tracing span.

The intention is to use workersCtx for all async tasks spawned from there.

However, as of this writing the following do not use workersCtx:

  • s.startSystemLogsGC()
  • startPurgeOldSessions()
  • s.ctSender.Run() (this one likely not affected, because it doesn't generate trace events)
  • s.startAttemptUpgrade() -- this is likely intentional: we probably want the ability to inspect a trace if the auto-upgrade fails. However, this intention should be marked with a comment.
  • s.node.tenantSettingsWatcher.Start()
  • s.kvProber.Start()
  • publishPendingLossOfQuorumRecoveryEvents()

Jira issue: CRDB-20832

@knz knz added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-observability-inf A-observability-inf labels Oct 24, 2022
@knz
Copy link
Contributor Author

knz commented Oct 24, 2022

Andrei says this doesn't leak memory because the RunAsyncTask calls under these functions already detach the trace.

@knz
Copy link
Contributor Author

knz commented Oct 24, 2022

The other reason to use workersCtx is that ctx has a log tag server start in it. It's not adequate to keep it for background tasks.

@knz knz changed the title server: possibly memory leak due to unneeded tracing of async goroutines server: background tasks incorrectly hang off the server start context Oct 24, 2022
@knz knz self-assigned this Oct 24, 2022
@craig craig bot closed this as completed in 852afd9 Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-observability-inf C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant