hanzhenfang commented on issue #13456:
URL: https://github.com/apache/apisix/issues/13456#issuecomment-4627353769
I also reproduce this issue with APISIX `3.16.0-debian` and Redis `7-alpine`.
## Environment
- APISIX image: `apache/apisix:3.16.0-debian`
- Redis image: `redis:7-alpine`
- Deployment mode: traditional mode with etcd
- Redis address used by both routes: `redis:6379`
## Reproduction Setup
I created two routes with the same Redis address but different Redis
databases.
Route 1:
```json
{
"uri": "/redis-db1",
"plugins": {
"limit-count": {
"policy": "redis",
"count": 1000,
"time_window": 60,
"key": "same-user",
"key_type": "constant",
"redis_host": "redis",
"redis_port": 6379,
"redis_database": 1,
"redis_keepalive_pool": 1,
"redis_keepalive_timeout": 60000
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"mock-ai-1:1980": 1
}
}
}
```
Route 2:
```json
{
"uri": "/redis-db2",
"plugins": {
"limit-count": {
"policy": "redis",
"count": 1000,
"time_window": 60,
"key": "same-user",
"key_type": "constant",
"redis_host": "redis",
"redis_port": 6379,
"redis_database": 2,
"redis_keepalive_pool": 1,
"redis_keepalive_timeout": 60000
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"mock-ai-1:1980": 1
}
}
}
```
Then I flushed DB 1 and DB 2:
```bash
redis-cli -n 1 FLUSHDB
redis-cli -n 2 FLUSHDB
```
Then I sent alternating requests:
```bash
for i in {1..50}; do
curl -s -o /dev/null http://127.0.0.1:9080/redis-db1
curl -s -o /dev/null http://127.0.0.1:9080/redis-db2
done
```
The upstream returned `404`, but that is unrelated to this issue. The
`X-RateLimit-*` headers were present, so the `limit-count` plugin had already
executed and accessed Redis.
## Expected Behavior
DB 1 should only contain keys for `/redis-db1`.
DB 2 should only contain keys for `/redis-db2`.
Expected:
```text
DB 1:
plugin-limit-count/apisix/routes/redis-db1:...:same-user
DB 2:
plugin-limit-count/apisix/routes/redis-db2:...:same-user
```
## Actual Behavior
Both DB 1 and DB 2 contained keys from both routes.
```text
DB 1:
plugin-limit-count/apisix/routes/redis-db1:1802751831:same-user
plugin-limit-count/apisix/routes/redis-db2:3762521015:same-user
DB 2:
plugin-limit-count/apisix/routes/redis-db1:1802751831:same-user
plugin-limit-count/apisix/routes/redis-db2:3762521015:same-user
```
The values also confirmed that both route counters were updated in both
databases:
```text
DB 1:
redis-db1 key = 962
redis-db2 key = 964
DB 2:
redis-db1 key = 988
redis-db2 key = 986
```
This means requests for `/redis-db1` and `/redis-db2` crossed Redis database
boundaries.
--
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]