Ivan Andika created HDDS-17965:
----------------------------------
Summary: OM listKeys can skip Unicode keys across page boundaries
Key: HDDS-17965
URL: https://issues.apache.org/jira/browse/HDDS-17965
Project: Apache Ozone
Issue Type: Bug
Reporter: Ivan Andika
Assignee: Ivan Andika
h3. Description
{{OmMetadataManagerImpl.listKeys()}} seeks in RocksDB using UTF-8 byte order,
then merges and sorts the results in a {{{}TreeMap<String, OmKeyInfo>{}}}. The
map uses Java’s natural string ordering, which compares UTF-16 code units.
These orderings can disagree for supplementary Unicode characters. When the
last key returned on one page becomes the next {{{}startKey{}}}, RocksDB can
seek past a key that LIST has yet to return. The issue also affects
{{{}ListKeysLight{}}}, which shares the same listing path. [Java
{{String.compareTo()}}
documentation|https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/String.html#compareTo(java.lang.String)]
h3. Reproduction
# In an object-store bucket, create and persist two keys with the same prefix.
In Java string literals, use {{"key-\uE000"}} and {{"key-\uD800\uDC00"}}
({{{}U+10000{}}}).
# Call {{listKeys}} with prefix {{{}key-{}}}, no {{{}startKey{}}}, and
{{{}maxKeys=1{}}}.
# Call {{listKeys}} again with the same prefix and page size, using the first
page’s key as {{{}startKey{}}}.
*Actual behavior.* The first page returns {{key-}} followed by {{{}U+10000{}}},
which sorts first in Java. The next page is empty because RocksDB places
{{U+E000}} before {{U+10000}} and seeks past it.
*Expected behavior.* The first page returns the key ending in {{{}U+E000{}}}.
The second returns the key ending in {{{}U+10000{}}}. Each key appears exactly
once.
h3. Proposed fix
Use RocksDB’s unsigned UTF-8 byte ordering consistently when comparing
{{startKey}} and the prefix, filtering cached entries, and ordering the merged
page. Add a regression test that pages through BMP and supplementary-character
keys from both RocksDB and the cache with {{{}maxKeys=1{}}}.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]