garnet
garnet copied to clipboard
Bug title: BITPOS failing at bit 0
Describe the bug
The command BITPOS for check for the first bit being 0 when the bits are all zeroe'd out is returning -1.
Steps to reproduce the bug
Result and response in Garnet with Redis CLI
172.18.224.1:6379> BITPOS mybitmap 0 0
(integer) 0
172.18.224.1:6379> SETBIT mybitmap 63 0
(integer) 0
172.18.224.1:6379> BITPOS mybitmap 0 1
(integer) -1
172.18.224.1:6379> BITPOS mybitmap 0 0
(integer) -1
Expected behavior
Result and response with Redis Server and Redis CLI
not connected> SETBIT mybitmap 0 0
(integer) 0
127.0.0.1:6379> SETBIT mybitmap 63 0
(integer) 0
127.0.0.1:6379> BITPOS mybitmap 0 1
(integer) 8
127.0.0.1:6379> BITPOS mybitmap 0 0
(integer) 0
Screenshots
No response
Release version
No response
IDE
No response
OS version
No response
Additional context
No response
Error is coming from https://github.com/microsoft/garnet/blob/e3c8a2064852d733285886252f450faa6a1e3d28/libs/server/Resp/Bitmap/BitmapManagerBitPos.cs#L185
In the case where i am looking for the first 0 in all 0's this flips it and exits, which is not the expected behavior here.
Fixed with #724