You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/07 11:21:39 UTC

[GitHub] [apisix] wfgydbu opened a new issue #2985: bug: 'limit-conn' plugin seems not working in an unexpected manner

wfgydbu opened a new issue #2985:
URL: https://github.com/apache/apisix/issues/2985


   ### Issue description
   'limit-conn' plugin seems not working in an unexpected manner
   
   ### Environment
   
   * apisix version (cmd: `apisix version`):2.1
   * OS: Centos 7.6
   
   ### Minimal test code / Steps to reproduce the issue
   1. Setup APISIX correctly. `make deps`, `make init`, `make run`
   2. Add one route contains `limit-conn`:
   ```
   curl -i -X PUT http://127.0.0.1:9080/apisix/admin/routes/1 -H'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '
   {
       "uri": "/*",
       "methods": ["PUT", "GET", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"],
   	"plugins": {
           "limit-conn": {
               "conn": 100,
               "burst": 0,
               "default_conn_delay": 0.1,
               "rejected_code": 503,
               "key": "remote_addr"
               }
   	},
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "10.10.10.40:8000": 10
           }
       }
   }'
   ```
   
   3. Test concurrency.  Keeps running `ab -c 1 -n 40 http://127.0.0.1:9080/` at least 3 times (let the number of requests exceeds limit value: 100) or more. 
   This command means to send 40 requests one by one.
   
   ### What's the actual result? (including assertion message & call stack if applicable)
   Starting from the third round, after sending the 100th request. **All the following requests will be blocked with 503 Code. ** It looks like the limitation work in a cumulative manner, not in a cocurrent manner.
   
   ### What's the expected result?
   the limit should never be touched, and all requests should return 200 OK.


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

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



[GitHub] [apisix] spacewander closed issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #2985:
URL: https://github.com/apache/apisix/issues/2985


   


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

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



[GitHub] [apisix] wfgydbu edited a comment on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
wfgydbu edited a comment on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740423200


   @spacewander  I have ran some tests based on your modifications in #2465, looks fine on my machine.


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

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



[GitHub] [apisix] wfgydbu commented on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
wfgydbu commented on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740423200


   @spacewander  I ran some tests based on your modifications in #2465, looks fine on my machine.


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

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



[GitHub] [apisix] spacewander commented on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740346852


   @wfgydbu 
   Would you try https://github.com/apache/apisix/pull/2465/files and report if the issue can be fixed by this?


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

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



[GitHub] [apisix] wfgydbu removed a comment on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
wfgydbu removed a comment on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740461818


   @spacewander @membphis  Hi friends, I'm wondering there might be another problem here.
   
   limit objs now are shared by using an `core.table`, Will it mess up two `limit-conn` in two different routes?
   
   Consider this, configure two routes:
   ```
   curl -i -X PUT http://127.0.0.1:9080/apisix/admin/routes/1 -H'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '
   {
       "uri": "/route1",
       "methods": ["PUT", "GET", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"],
   	"plugins": {
           "proxy-rewrite": {
               "uri": "/"
           },
           "limit-conn": {
               "conn": 20,
               "burst": 0,
               "default_conn_delay": 0.1,
               "rejected_code": 503,
               "key": "remote_addr"
               }
   	},
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "10.10.10.40:8000": 10
           }
       }
   }'
   
   
   
   curl -i -X PUT http://127.0.0.1:9080/apisix/admin/routes/2 -H'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '
   {
       "uri": "/route2",
       "methods": ["PUT", "GET", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"],
   	"plugins": {
           "proxy-rewrite": {
               "uri": "/"
           },
           "limit-conn": {
               "conn": 50,
               "burst": 0,
               "default_conn_delay": 0.1,
               "rejected_code": 503,
               "key": "remote_addr"
               }
   	},
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "10.10.10.40:8000": 10
           }
       }
   }'
   ```
   Then run `ab -c 10 -n 10000 http://127.0.0.1:9080/route1` and `ab -c 40 -n 10000 http://127.0.0.1:9080/route2` at the same time. The Result contains 503 error code that should not have. Because  10 < 20 and 40 < 50). 
   
   Results:
   ```
   Document Path:          /route1
   Document Length:        214 bytes
   Concurrency Level:      10
   Time taken for tests:   4.530 seconds
   Complete requests:      10000
   Failed requests:        9663
      (Connect: 0, Receive: 0, Length: 9663, Exceptions: 0)
   Write errors:           0
   Non-2xx responses:      9663
   
   Document Path:          /route2
   Document Length:        214 bytes
   Concurrency Level:      40
   Time taken for tests:   10.496 seconds
   Complete requests:      10000
   Failed requests:        0
   Write errors:           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.

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



[GitHub] [apisix] wfgydbu commented on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
wfgydbu commented on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740349882


   Sure. I'd like to.


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

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



[GitHub] [apisix] spacewander commented on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-742281538


   Solved by #2465 


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

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



[GitHub] [apisix] wfgydbu edited a comment on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
wfgydbu edited a comment on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740344661


   https://github.com/apache/apisix/blob/v2.1/apisix/plugins/limit-conn.lua#L88-L94
   
   I think these code should be something like this:
   ```
       if lim:is_committed() then
           if not ctx.limit_conn then
               ctx.limit_conn = core.tablepool.fetch("plugin#limit-conn", 0, 6)
           end
   
           core.table.insert_tail(ctx.limit_conn, lim, key, delay)
       end
   ```


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

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



[GitHub] [apisix] wfgydbu commented on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
wfgydbu commented on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740344661


   https://github.com/apache/apisix/blob/v2.1/apisix/plugins/limit-conn.lua#L88-L94
   
   I think these code should be something like this:
   ```
       if lim:is_committed() then
           if not ctx.limit_conn then
               ctx.limit_conn = core.tablepool.fetch("plugin#limit-conn", 0, 6)
   
           core.table.insert_tail(ctx.limit_conn, lim, key, delay)
           end
       end
   ```


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

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



[GitHub] [apisix] wfgydbu commented on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
wfgydbu commented on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740461818


   @spacewander @membphis  Hi friends, I'm wondering there might be another problem here.
   
   limit objs now are shared by using an `core.table`, Will it mess up two `limit-conn` in two different routes?
   
   Consider this, configure two routes:
   ```
   curl -i -X PUT http://127.0.0.1:9080/apisix/admin/routes/1 -H'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '
   {
       "uri": "/route1",
       "methods": ["PUT", "GET", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"],
   	"plugins": {
           "proxy-rewrite": {
               "uri": "/"
           },
           "limit-conn": {
               "conn": 20,
               "burst": 0,
               "default_conn_delay": 0.1,
               "rejected_code": 503,
               "key": "constant"
               }
   	},
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "10.10.10.40:8000": 10
           }
       }
   }'
   
   
   
   curl -i -X PUT http://127.0.0.1:9080/apisix/admin/routes/2 -H'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '
   {
       "uri": "/route2",
       "methods": ["PUT", "GET", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"],
   	"plugins": {
           "proxy-rewrite": {
               "uri": "/"
           },
           "limit-conn": {
               "conn": 50,
               "burst": 0,
               "default_conn_delay": 0.1,
               "rejected_code": 503,
               "key": "constant"
               }
   	},
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "10.10.10.40:8000": 10
           }
       }
   }'
   ```
   Then run `ab -c 10 -n 10000 http://127.0.0.1:9080/route1` and `ab -c 40 -n 10000 http://127.0.0.1:9080/route2` at the same time. The Result contains 503 error code that should not have. Because  10 < 20 and 40 < 50). 
   
   Results:
   ```
   Document Path:          /route1
   Document Length:        214 bytes
   Concurrency Level:      10
   Time taken for tests:   4.530 seconds
   Complete requests:      10000
   Failed requests:        9663
      (Connect: 0, Receive: 0, Length: 9663, Exceptions: 0)
   Write errors:           0
   Non-2xx responses:      9663
   
   Document Path:          /route2
   Document Length:        214 bytes
   Concurrency Level:      40
   Time taken for tests:   10.496 seconds
   Complete requests:      10000
   Failed requests:        0
   Write errors:           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.

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



[GitHub] [apisix] wfgydbu edited a comment on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
wfgydbu edited a comment on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740461818


   @spacewander @membphis  Hi friends, I'm wondering there might be another problem here.
   
   limit objs now are shared by using an `core.table`, Will it mess up two `limit-conn` in two different routes?
   
   Consider this, configure two routes:
   ```
   curl -i -X PUT http://127.0.0.1:9080/apisix/admin/routes/1 -H'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '
   {
       "uri": "/route1",
       "methods": ["PUT", "GET", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"],
   	"plugins": {
           "proxy-rewrite": {
               "uri": "/"
           },
           "limit-conn": {
               "conn": 20,
               "burst": 0,
               "default_conn_delay": 0.1,
               "rejected_code": 503,
               "key": "remote_addr"
               }
   	},
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "10.10.10.40:8000": 10
           }
       }
   }'
   
   
   
   curl -i -X PUT http://127.0.0.1:9080/apisix/admin/routes/2 -H'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '
   {
       "uri": "/route2",
       "methods": ["PUT", "GET", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"],
   	"plugins": {
           "proxy-rewrite": {
               "uri": "/"
           },
           "limit-conn": {
               "conn": 50,
               "burst": 0,
               "default_conn_delay": 0.1,
               "rejected_code": 503,
               "key": "remote_addr"
               }
   	},
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "10.10.10.40:8000": 10
           }
       }
   }'
   ```
   Then run `ab -c 10 -n 10000 http://127.0.0.1:9080/route1` and `ab -c 40 -n 10000 http://127.0.0.1:9080/route2` at the same time. The Result contains 503 error code that should not have. Because  10 < 20 and 40 < 50). 
   
   Results:
   ```
   Document Path:          /route1
   Document Length:        214 bytes
   Concurrency Level:      10
   Time taken for tests:   4.530 seconds
   Complete requests:      10000
   Failed requests:        9663
      (Connect: 0, Receive: 0, Length: 9663, Exceptions: 0)
   Write errors:           0
   Non-2xx responses:      9663
   
   Document Path:          /route2
   Document Length:        214 bytes
   Concurrency Level:      40
   Time taken for tests:   10.496 seconds
   Complete requests:      10000
   Failed requests:        0
   Write errors:           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.

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



[GitHub] [apisix] spacewander commented on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740438612


   Good to know. BTW, it is @membphis 's modifications.
   @membphis 
   Would you solve the conflict in #2465 ?


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

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



[GitHub] [apisix] membphis commented on issue #2985: bug: 'limit-conn' plugin seems working in an unexpected manner

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2985:
URL: https://github.com/apache/apisix/issues/2985#issuecomment-740451592


   fixed the conflict right now ^_^


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

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