Happy new year everyone, recently we found an issue in current unstable version of Redis cli interactive mode, db number mismatches when wrapping select db command in MULTI if we discard the transaction later on, following is an example, note initially db 0 and 5 are empty:

127.0.0.1:6379> set foo db0 OK 127.0.0.1:6379> select 5 OK 127.0.0.1:6379[5]> set foo db5 OK 127.0.0.1:6379[5]> select 0 OK 127.0.0.1:6379> multi OK 127.0.0.1:6379> select 5 QUEUED 127.0.0.1:6379[5]> discard OK 127.0.0.1:6379[5]> get foo "db0" 127.0.0.1:6379[5]>

Please note the current db is still in 0 but the display shows in db5. I did a fix in the following PR, can anyone take look this? thanks you very much!

Comment From: hwware

https://github.com/antirez/redis/pull/6728

Comment From: hwware

@antirez @artix75 @itamarhaber can anyone take look this issue please? thanks!

Comment From: itamarhaber

Hello @hwware

Thanks for reporting the issue and a PR. The issue, while minor, is real and should be addressed - I added a few comments to your PR but it would be better to get more eyes on this.

Comment From: hwware

Hello @itamarhaber, thank you very much for your comments, I had the PR fixed based on these. I tested the following scenario: 1. Success multi/exec 2. Success multi/discard 3. Failed multi/exec 4. Multiple multi 5. Exec without multi 6. Discard without multi and the db number looks correct, please let me know if I miss anything with this PR, thank you very much!