Revolyssup opened a new pull request, #12451:
URL: https://github.com/apache/apisix/pull/12451

   ### Description
   ## Reproduction steps
   ```bash
   curl http://127.0.0.1:9180/apisix/admin/routes/3 -H "X-API-KEY: 
rycegJXdCGBWaFwXbadcNvcbgYgwOmyG" -X PUT -d '
   {
       "uri": "/status/*",
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "httpbin.org:80": 1
           }
       },
       "plugins": {
           "api-breaker": {
               "break_response_code": 599,
               "break_response_body": "触发熔断",
               "max_breaker_sec": 60,
               "unhealthy": {
                   "http_statuses": [
                       500,
                       502,
                       503
                   ],
                   "failures": 5
               },
               "healthy": {
                   "http_statuses": [
                       200,
                       201,
                       202,
                       203,
                       301,
                       302,
                       304,
                       400,
                       401,
                       403,
                       404,
                       413,
                       429
                   ],
                   "successes": 3
               }
           }
       }
   }'
   
   while true; do
     timestamp=$(date +"[%Y-%m-%d %H:%M:%S]")
     status_code=$(curl -s -o /dev/null -w "%{http_code}" 
"http://127.0.0.1:9080/status/500";)
     echo "$timestamp $status_code"
     sleep 1
   done
   
   ```
   
   ```error.log
   [2025-07-09 17:03:20] 500
   [2025-07-09 17:03:21] 500
   [2025-07-09 17:03:24] 500
   [2025-07-09 17:03:25] 500
   [2025-07-09 17:03:27] 500
   [2025-07-09 17:03:28] 599
   [2025-07-09 17:03:29] 599
   [2025-07-09 17:03:30] 500
   [2025-07-09 17:03:33] 500
   [2025-07-09 17:03:34] 500
   [2025-07-09 17:03:36] 500
   [2025-07-09 17:03:39] 502
   [2025-07-09 17:03:41] 599
   [2025-07-09 17:03:42] 599
   [2025-07-09 17:03:43] 599
   [2025-07-09 17:03:44] 599
   [2025-07-09 17:03:45] 500
   [2025-07-09 17:03:47] 599
   [2025-07-09 17:03:48] 599
   [2025-07-09 17:03:49] 500
   ```
   
   ## Description
   The circuit breaker did not operate as configured. In the following logs, 
the circuit breaker condition is triggered by 5 occurrences of 500/502/503 
responses, and lines 18 and 19 should not have tripped
   
   
   ## Reason
   When set to ceil breaker_time is prematurely increased causing 
inconsistency. Consider the flow​:
   5 requests fail->2 second breaker_time->6th request fail and due to ceil, 
breaker_time is immediately set to 4 seconds. So if 7th request comes just 
before 4 seconds, it will be blocked as well. 
   The behaviour should be 5 requests fail->2 second circuit break->5 more 
requests fail->4 second circuit break->5 more requests fail->8 second circuit 
break.... And so on
   
   
   ### Checklist
   
   - [ ] I have explained the need for this PR and the problem it solves
   - [ ] I have explained the changes or the new features added to this PR
   - [ ] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [ ] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to