Firstsawyou opened a new issue #3740:
URL: https://github.com/apache/apisix/issues/3740


   ### Issue description
   
   When both the routing and traffic-split plugins use upstream_id to bind 
upstream, the request distribution is not accurate.
   
   1、add route and bind plugin
   
   The upstream_id is 1, the response data is 1980, and the upstream_id is 2 
the response data is 1981.
   
   ```shell
   curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "create_time":1614743731,
       "update_time":1614745342,
       "uris":[
           "/*"
       ],
       "name":"luarocks_cn",
       "methods":[
           "GET",
           "HEAD",
           "POST",
           "PUT",
           "DELETE",
           "OPTIONS",
           "PATCH"
       ],   
       "vars":[
   
       ],
       "plugins":{
           "proxy-rewrite":{
               "disable":false,
               "scheme":"http"
           },
           "traffic-split":{
               "disable":false,
               "rules":[
                   {
                       "match":[
                           {
                               "vars":[
                                   [
                                       "uri",
                                       "==",
                                       "/hello"
                                   ]
                               ]
                           }
                       ],
                       "weighted_upstreams":[
                           {
                               "upstream_id":"2"
                           }
                       ]
                   }
               ]
           }
       },
       "upstream_id":"1",
       "status":1
   }
   '
   ```
   
   2、Test plugin
   
   The vars rule passes:
   ```shell
   $ curl http://127.0.0.1:9080/hello
   1981
   ```
   
   The vars rule failed:
   
   ```shell
   $ curl http://127.0.0.1:9080/hello12
   1980
   ```
   
   The vars rule passes:
   ```shell
   $ curl http://127.0.0.1:9080/hello
   1981
   ```
   
   The vars rule failed (an exception occurred):
   
   ```shell
   $ curl http://127.0.0.1:9080/hello12
   1981
   ```
   


----------------------------------------------------------------
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:
[email protected]


Reply via email to