moonming commented on PR #14239: URL: https://github.com/apache/apisix/pull/14239#issuecomment-7034720050
I compared `55aeb228` with the PR base `2ea174cd`. I would address the following three risks before merging. The latest commit changes test expectations and timing; the relevant production code is unchanged. 1. **A new `limit-conn` lease can expire early even without a configuration update.** The base refreshed the Redis key on every admission. The new comparison uses whole seconds. In a Redis 8 test of the PR's Lua script, a key with 2800 ms left reported `TTL = 3`. The script admitted a new 3-second lease, but the key had only 2796 ms left immediately afterwards. Please compare `PTTL` against `ttl * 1000` and extend with `PEXPIRE` when needed, preserving the existing non-positive TTL behavior. A regression should cover the case where the rounded seconds are equal. [Lease script](https://github.com/apache/apisix/blob/55aeb2285d0e0f6071a8bcc7ab558a3892e05c9b/apisix/plugins/limit-conn/util.lua#L39-L46) 2. **Delayed `limit-count` sync can mix accounting across Redis databases after a configuration update.** For an ungrouped PluginConfig, changing DB 14 to DB 15 previously changed the configuration hash and therefore the local accounting key. With the new key, both generations can read the same cached remote balance and pending delta, even though their timers target different databases. A new request can be judged against DB 14's balance, and which backend receives a pending delta can depend on timer order. This is a source finding; I have not reproduced the timer interleaving. Please keep pending consumption associated with its original backend. A useful regression would leave a delta pending in DB 14, switch to DB 15, send another request, then assert the final counts in **both** databases after both timers drain. [Counter identity](https://github.com/apache/apisix/blob/55aeb2285d0e0f6071a8bcc7ab558a3892e05c9b/apisix/plugins/limit-count/init.lua#L362-L394) · [Local balance and delta keys](https://github.com/apache/apisix/blob/55aeb2285d0e0f6071a8bcc7ab558a3892e05c9b/apisix/plugins/limit-count/delayed-syncer.lua#L68-L99) · [Flush path](https://github.com/apache/apisix/blob/55aeb2285d0e0f6071a8bcc7ab558a3892e05c9b/apisix/plugins/limit-count/delayed-syncer.lua#L358-L374) 3. **Changing a statically configured sliding-window length can reuse counts from a different window.** The base gave a static `time_window` change a different configuration hash. The new sliding key omits the length, and `floor(now / time_window)` does not uniquely identify it. For example, at Unix time `1795176000`, both 86400 and 86401 seconds yield window ID `20777`. The new configuration can read the same count and weight it using different window boundaries. Please include the resolved length in the sliding counter identity if changing the length should start a new window, and test lengths with the same window ID. The regression here is the **static configuration update**; dynamic values from an unchanged expression could already encounter this boundary on the base. [Key construction](https://github.com/apache/apisix/blob/55aeb2285d0e0f6071a8bcc7ab558a3892e05c9b/apisix/plugins/limit-count/init.lua#L375-L394) · [Window ID](https://github.com/apache/apisix/blob/55aeb2285d0e0f 6071a8bcc7ab558a3892e05c9b/apisix/plugins/limit-count/sliding-window/sliding-window.lua#L35-L49) **One gap in the new `limit-req` behavior:** the base reset the bucket immediately on a rate change. This PR promises to preserve the debt, but slowing the rate can preserve it only until the old TTL expires. With the Redis script, I filled a bucket at `rate=10, burst=2`, changed the rate to `0.1`, and observed a rejection followed by a fresh admission about 2.2 seconds later. The rejection returns before the expiry update. Please test the slower-rate case across the old expiry and define how long the outstanding debt should survive, including when requests continue to be rejected. Both Redis observations above are script-level checks, not full gateway runs. [Redis bucket update](https://github.com/apache/apisix/blob/55aeb2285d0e0f6071a8bcc7ab558a3892e05c9b/apisix/plugins/limit-req/util.lua#L54-L77) For the new regression tests, please also scope Redis cleanup to keys owned by each test resource. The helper predates this PR, but the three new suites add 12 calls to it; it issues `FLUSHALL` on multiple ports and can remove another concurrently running test's counters. [Cleanup helper](https://github.com/apache/apisix/blob/55aeb2285d0e0f6071a8bcc7ab558a3892e05c9b/t/lib/test_redis.lua#L123-L159) -- 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]
