krm* functions assume the key range is initialized to a default value, and return incorrect results if not
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 1.6k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 126
Description
i have a completely empty database, and i do krmSet("prefix", KeyRangeRef(A, B), 1) to set the range [A-B)=1
I'd expect this to produce in the database:
`prefixA=1`
`prefixB=`
And then if i do krmRead("prefix", normalKeys)
I'd expect to get
`prefixA=1`
`prefixB=`
or
`prefix=`
`prefixA=1`
`prefixB=`
What I get is
`prefix=1`
`prefixA=1`
`prefixB=empty`
which is incorrect, because I never set ['' - 'A') to 1.
krm* is assuming that, before calling krmRead("prefix", normalKeys), i explicitly do krmSet("prefix", normalKeys, defaultValue);
I tried a fix but it hit some other errors in other places, so it's not as obvious of a fix as I initially thought. We should fix it as this behavior is not intuitive, and it would save someone else some debugging time that I had to spend.
Contributor guide
Research direction
Start by locating the krmSet and krmRead implementations and their handling of an empty database. Reproduce the reported KeyRangeRef(A, B) case with krmSet("prefix", KeyRangeRef(A, B), 1), then check the results from krmRead("prefix", normalKeys). Done means the unset range before A is not reported as 1 and the returned values match the documented key-range behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100