Repository navigation
perf(coderd/x/plugins): stop lease polling while no plugin is enabled - #349
Conversation
A replica that runs no plugin reads GetPluginLeaseSummary, which takes no lock and writes nothing, and calls AcquirePluginLeases only when a plugin is free to lease. With no enabled plugin the lease loop waits for plugins:changed and checks once every 5 minutes. A standby replica and a replica without the pubsub subscription keep the 10 s interval. Part of #305.
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…untime-polling-ad3bca66
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2793638bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…untime-polling-ad3bca66
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…untime-polling-ad3bca66
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…untime-polling-ad3bca66
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merged at head Gates on this exact head:
Not exercised: a live deployment with Wasm plugins enabled and disabled. The lease loop behavior is checked by unit tests with a mock clock only. |
Part of #305 (item 1). The chat binding change (item 3) is a separate PR.
Problem
The plugin lease loop ran
AcquirePluginLeases, anUPDATEwithRETURNING *, every 10 s on every replica, even with no plugin installed or enabled. That is 60 writes in 10 idle minutes.Change
GetPluginLeaseSummary: counts enabled plugins and the ones this replica could lease now (its own, free or expired). It takes no lock and writes nothing.Manager.reconcilereads the summary while the replica runs no plugin and callsAcquirePluginLeasesonly when a plugin is free to take. A replica that runs a plugin renews as before.plugins:changedand checks once every 5 minutes (Options.IdleInterval) in case a message was lost. A standby replica (enabled plugin held by another replica) keeps the 10 s interval so it can take over an expired lease. A replica whoseplugins:changedsubscription failed also keeps 10 s.manager.godescribes the loop.Install, patch and delete already publish
plugins:changed(coderd/plugins.go), so an enabled plugin starts at once, as before.Tests
TestManagerIdleIssuesNoWrites: zero plugins, quartz mock clock, 10 minutes. Two summary reads after start, noAcquirePluginLeases, no other statement (strict gomock).TestManagerIdlePicksUpChanges: enable throughplugins:changedwhile idle takes the lease at once; disable returns to the 5 minute idle interval after one 10 s check; an enable whose message was lost is found by the next idle check.TestManagerStandbyWatchesLeases: a held plugin keeps the 10 s interval without writes, and an expired lease is taken.TestManagerIdleWithoutSubscription: no subscription keeps 10 s.TestManagerRenewalCountsReconcileTime: a renewal that takes 4 s waits 6 s for the next one, and one that takes longer than the interval fires the next at once. Fails without the fix (expected 6s, actual 10s).TestPluginLeases(Postgres) checks the summary for free, held, released and disabled plugins.Negative control on
mainbefore this change: a test with the same setup (idle manager, 60 xAdvance(10s)) counted 60AcquirePluginLeasescalls in 10 minutes.Commands run, all passed:
Not done here
perf(coderd/x/plugins): stop lease polling while no plugin is enabled #349 and perf(coderd/x/plugins): bind only new chats on each delivery #351 both edit the package doc in
manager.goandfork_forkdb_test.go, so whichever merges second needsmainmerged in first.Item 2 of plugins: the runtime polls with nothing to run and rebinds every chat every 15 s #305 (renewal without
RETURNING *and decrypt) and item 4 (restart backoff) are not in this PR.Not exercised against a multi-replica deployment; the standby path is covered by the mock test and the Postgres summary test.