jakubzieba opened a new issue, #14063:
URL: https://github.com/apache/apisix/issues/14063

   ### Current Behavior
   
   When we configure the limit-count plugin with multiple rules and set the 
sync_interval option, after the first synchronization with Redis, the remaining 
request counter for the other rules will be set to the value of the first rule. 
   
   Let's assume we have a route defined like the one below:
   ```json
   {
     "name": "route",
     "uri": "/route",
     "upstream": {
       "type": "roundrobin",
       "nodes": {
         "web1:80": 1
       }
     },
     "plugins": {
       "limit-count": {
         "rejected_code": 429,
         "policy": "redis",
         "rejected_msg": "too many requests",
         "redis_host": "redis",
         "redis_port": 56379,
         "redis_database": 1,
         "sync_interval": 10,
         "rules": [
           {
             "count": 30,
             "time_window": 60,
             "key": "${http_x_real_ip}_per_minute",
             "header_prefix": "rule1"
           },
           {
             "count": 500,
             "time_window": 3600,
             "key": "${http_x_real_ip}_per_hour",
             "header_prefix": "rule2"
           }
         ]
       }
     }
   }
   ```
   now, after the first request, the "Remaining" counters are correct.
   <img width="832" height="187" alt="Image" 
src="https://github.com/user-attachments/assets/b227b134-2ef3-44fa-b83d-15932c4f0120";
 />
   
   After waiting 10 seconds (until the counter synchronization with Redis 
completes), it is already incorrect because the 'Remaining' counter for rule2 
becomes the same as for rule1.
   <img width="937" height="170" alt="Image" 
src="https://github.com/user-attachments/assets/d4dc3b4a-e24d-4c02-9550-1e62dcb08c82";
 />
   
   It seems that after synchronizing the counters, the 'Remaining' value from 
the first rule is incorrectly assigned to all subsequent rules.
   
   When we disable the sync_interval option, everything works as expected, and 
each rule has its correct 'Remaining' counter.
   
   ### Expected Behavior
   
   Each rule should have the correct 'Remaining' counter value, regardless of 
whether sync_interval is enabled or disabled.
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   1. Ensure your APISIX instance is up and running.
   2. Configure and create the route as specified in the Current Behavior 
section.
   3. Execute a request to http://localhost:9080/route and inspect the response 
headers X-Rule1-Ratelimit-Remaining and X-Rule2-Ratelimit-Remaining
   4. Wait for 10 seconds (corresponding to the configured sync_interval value).
   5. Make the request again and verify that the X-Rule1-Ratelimit-Remaining 
and X-Rule2-Ratelimit-Remaining header have same values.
   
   ### Environment
   
   - APISIX version: 3.18.0
   


-- 
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]

Reply via email to