Skip to content

Sync plugin settings and status across replicas - #1658

Open
efegokdemir wants to merge 3 commits into
apache:devfrom
efegokdemir:efe/plugin-settings-sync
Open

efegokdemir wants to merge 3 commits into
apache:devfrom
efegokdemir:efe/plugin-settings-sync

Conversation

@efegokdemir

@efegokdemir efegokdemir commented Oct 29, 2026 •

Copy link
Copy Markdown

Fixes #1657

Proposed Changes

  • Refresh plugin status and configuration from the database every 10 seconds on each instance.
  • Use a conditional update for plugin status so concurrent changes from other instances are preserved.

Limitations

Enabling or disabling a cache plugin updates the status/config snapshot, but data.Cache selects its backend during process startup. Restart the instance for cache selection changes to take effect.

Tests: go test ./internal/service/plugin_common ./internal/repo/config ./plugin/... ./internal/controller_admin passed. Targeted golangci-lint run reported 0 issues.

@LinkinStars
LinkinStars changed the base branch from main to dev November 5, 2026 08:56
@LinkinStars

Copy link
Copy Markdown
Member

Thanks for working on the cross-replica plugin sync. Reading the persisted status before a conditional update is a useful fix for concurrent changes.

Could we consider reducing the continuous database polling in this PR? Each replica currently reads the status and the full plugin-config table every 10 seconds. A possible alternative is to keep a local status snapshot with a roughly one-minute TTL: use it for normal plugin checks, and refresh the whole snapshot from the database on the first check after it expires. Plugin configuration would still need its own less frequent refresh (for example, every minute), since loading a status value alone does not call ConfigReceiver or update the plugin's in-process state. A delay of up to about one minute for changes to reach other replicas would be acceptable to us.

I would keep the database as the source of truth and retain the conditional status update. Even with a shared cache, reading status from it would not apply configuration to plugin instances. If you pursue the TTL approach, please retain the explicit startup load, bypass the config cache for refreshes, coalesce concurrent expired reads, and ensure a failed or older refresh cannot overwrite a successful local update.

What do you think of this direction?

@haosb

haosb commented Nov 30, 2026

Copy link
Copy Markdown

Hello, any updates here? Must have feature for the Kubernetes HA deployments

@LinkinStars LinkinStars self-assigned this Dec 2, 2026
@LinkinStars
LinkinStars self-requested a review December 2, 2026 07:18

@LinkinStars LinkinStars left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for updating the implementation along the direction we discussed. The one-minute status TTL, independent configuration refresh, direct database reads, and conditional status updates match our expectations.

We tested against Docker MySQL 8.4.13 with official Redis, Meilisearch, memory vector-search, captcha, OAuth, S3 storage/CDN, and Slack plugins. Existing configuration loading, existing-user login after upgrading from dev, immediate local updates, and cross-replica refresh were verified. Google/OAuth/S3/embedding upstreams used local test endpoints; Redis and Meilisearch used real services. We did not send notifications or upload to real cloud services.

I have attached inline comments for the remaining activation-lifecycle, reload-thread-safety, and lock-scope concerns, including the reproduced behavior and suggested direction. As noted inline, some lifecycle and plugin-thread-safety gaps already exist in older local-update paths; they should not all be described as new regressions.

Please also document the rolling-upgrade limitation: in our real HTTP test, a still-running dev replica overwrote a newer replica's status changes with its whole stale snapshot. Plugin status changes should be avoided until all replicas have been upgraded; the new conditional writer cannot prevent an old unconditional writer from doing this.

Signed-off-by: Efe Gökdemir <efe@rexcode.co.uk>

This branch has not been deployed

No deployments
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.

Plugin settings changes don’t reach other instances in a multi-replica setup

3 participants