moonming commented on PR #14239: URL: https://github.com/apache/apisix/pull/14239#issuecomment-7039592294
Rechecked `f8072a24`. The millisecond lease test and the test that observes two Redis members for two successful reservations on the same key are worth keeping. I found two remaining correctness issues in delayed `limit-count` sync that I would address before merging. 1. **Raising a sliding-window limit can grant too much quota.** Consider a window halfway through, with 8 requests in the previous window and 1 in the current window. A syncer running with limit 2 caps the previous count at 2 and records a remaining quota of 0. When the limit rises to 10, the reader computes `0 + 10 - 2 = 8`. Reading the same underlying counts with limit 10 gives `10 - 1 - 8 × 0.5 = 5`. I verified **8 vs. 5** in an isolated Redis 8 component check using this head's window calculation and a fixed clock. The full gateway timer interleaving still needs a regression. Could the sliding path recompute from the original counts when the threshold changes? The fixed-window arithmetic can stay as it is. The regression should let the old syncer write its snapshot and compare the new reader's allowance with the direct sliding-window calculation at the same point in the window. [Window calculation](https://github.com/apache/apisix/blob/f8072a24db8f76ee3f6b79e06636667c7297ec0d /apisix/plugins/limit-count/sliding-window/sliding-window.lua#L196-L217) · [Quota adjustment](https://github.com/apache/apisix/blob/f8072a24db8f76ee3f6b79e06636667c7297ec0d/apisix/plugins/limit-count/delayed-syncer.lua#L223-L235) 2. **Changing from fixed to sliding can flush pending requests through the wrong algorithm.** On an ungrouped route, keep the Redis DB, subject, and 60-second window unchanged and switch only `window_type`. Both syncers address the same local pending delta, cached balance, and lock, although they flush through different limiter implementations. From the source, the old timer can pick up a request admitted under the new algorithm. I haven't reproduced that scheduling sequence end to end. Please scope the local accounting to the window algorithm. A regression can leave two fixed-window admissions pending, confirm they have not reached Redis, switch to sliding, admit one more, then drain both timers and assert **2 in the fixed bucket and 1 in the sliding bucket**. [Local accounting keys](https://github.com/apache/apisix/blob/f8072a24db8f76ee3f6b79e06636667c7297ec0d/apisix/plugins/limit-count/delayed-syncer.lua#L70-L99) · [Syncer construction](https://github.com/apache/apisix/blob/f8 072a24db8f76ee3f6b79e06636667c7297ec0d/apisix/plugins/limit-count/limit-count-redis.lua#L58-L89) Three regression-test improvements would also help: - **Same database after a credential change.** The DB 14 → 15 test covers moving counters. Please also exercise the inverse: leave two admissions pending at a limit of 2, then switch to another ACL user with access to the same keys in the same DB. The third request should still be rejected. The local accounting identity currently includes the username and also depends on the order of cluster seed nodes. A credential rotation or seed-list reorder can therefore hide pending usage even though the remote data is unchanged. This is a source finding. [Backend identity](https://github.com/apache/apisix/blob/f8072a24db8f76ee3f6b79e06636667c7297ec0d/apisix/plugins/limit-count/delayed-syncer.lua#L503-L521) - **Cleanup isolation.** Removing `FLUSHALL` helps. In Redis 8 I verified that the replacement glob `*/apisix/routes/lconn-conf-update[:#]*` still selects a different route's key, `limit_conn:/apisix/routes/peer:client/apisix/routes/lconn-conf-update:blue`. The helper then deletes every match. Please use a per-run resource ID and match from the actual plugin prefix. An effective assertion is to keep a peer reservation live throughout cleanup and check that its exact member survives. [Current pattern](https://github.com/apache/apisix/blob/f8072a24db8f76ee3f6b79e06636667c7297ec0d/t/plugin/limit-conn-conf-update.t#L35-L41) · [Peer-reservation test in #14226](https://github.com/apache/apisix/blob/331cbc8e7e0a2dc1eae13e7ccc173367c68fb8f4/t/cli/limit_conn_identity.py#L316-L331) - **Cross-worker updates and late release.** The current helper sleeps after publishing the config and starting a held request. For the lifecycle regression, confirm two distinct worker PIDs have observed the new configuration, use an upstream signal to hold and release the original request, then check that the replacement request's exact Redis member survives the old request's late release. A final cardinality alone can hide removal of the wrong member. [Current helper](https://github.com/apache/apisix/blob/f8072a24db8f76ee3f6b79e06636667c7297ec0d/t/plugin/limit-conn-conf-update.t#L43-L89) · [Mixed-lease regression in #14226](https://github.com/apache/apisix/blob/331cbc8e7e0a2dc1eae13e7ccc173367c68fb8f4/t/cli/limit_conn_identity.py#L376-L399) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
