Skip to content

Serialize APISIX standalone cache-miss dump with sync per cache key #571

Description

@coderabbitai

Summary

Serialize a cache-miss Backend::dump commit with Backend::sync for the same cache_key.

Rationale

A cache-miss dump can fetch an older standalone configuration while a sync completes. If dump then calls Cache::set_dump_result, it can replace the cache configuration and raw configuration with the older snapshot. A later unpinned sync can then build its document from stale state.

Concurrent sync requests for the same cache_key are outside the current operational model. This issue tracks the planned per-key locking needed to enforce that model and to prevent dump-versus-sync state replacement.

Required changes

  • Add a per-key synchronization mechanism for rust/crates/adc-backend-apisix-standalone/src/backend.rs and the related cache flow.
  • Serialize cache-miss Fetcher::dump execution and its cache commit with sync for the same cache_key, or use a generation check that rejects a fetched snapshot superseded by sync.
  • Preserve independent operation for different cache keys.
  • Add a coordinated regression test that verifies an older cache-miss dump cannot overwrite state written by sync.

Affected areas

  • rust/crates/adc-backend-apisix-standalone/src/backend.rs
  • rust/crates/adc-backend-apisix-standalone/src/cache.rs
  • APISIX standalone backend cache and synchronization tests

Acceptance criteria

  • A cache-miss dump cannot commit stale configuration after a sync for the same cache key completes.
  • The cache configuration, raw configuration, and latest version remain mutually consistent.
  • The regression test deterministically covers the dump-versus-sync ordering.

Backlinks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions