Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Bug] Upper-case hex in cloud initial rowset id is mis-parsed by BE from_hex (lossy, non-unique RowsetId)

オープン 初心者向け
#69,371 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, java
領域
backend, databases

調査の方向性

まず be/src/util/uid_util.h と be/src/storage/rowset_id.cpp を読み、次に issue で言及されている from_hex() の呼び出し元を調べてください。大文字の解析ケースを再現し、UID または rowset ID の解析に関する既存の単体テストを確認してください。大文字の 16 進数が小文字と同じ値に解析され、無効な文字が安全に処理されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Search before asking
  • I had searched in the issues and found no similar issues.
Version

4.1.4 (cloud mode). master is the same (351d9388d5):

  • FE fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java:690-692 builds the initial [0-1] rowset id with String.format("%016X", ...) (upper-case hex).
  • BE be/src/util/uid_util.h:48-61 from_hex() only handles 0-9 and a-f; any other character is mapped with c - 'a' + 10.
  • BE be/src/storage/rowset_id.cpp:57-63 RowsetId::init(std::string_view) parses the 48-char id with from_hex().
Description

In cloud mode the FE creates the empty [0-1] rowset of every new tablet with a V2 rowset id formatted as upper-case hex:

String rowsetIdV2Str = String.format("%016X", 2L << 56)
        + String.format("%016X", uuid.getMostSignificantBits())
        + String.format("%016X", uuid.getLeastSignificantBits());

The BE parses rowset ids with from_hex(), which treats every non-digit as lower-case:

if (i >= '0' && i <= '9') {
    buf_val = i - '0';
} else {
    buf_val = i - 'a' + 10;   // 'A'..'F' -> -22..-17
}
val <<= 4;
val = val | buf_val;          // a negative nibble sets all upper bits

For 'A'..'F' the nibble is negative, so val | buf_val sets every higher bit. Any UUID half that contains an upper-case letter parses to a value like 0xffffffffffffffea. The BE then shows these rowsets as, e.g.,

0200000000000000ffffffffffffffeafffffffffffffffe

Consequences:

  1. The parse is lossy: everything before the last letter in each 16-char half is lost, so [0-1] rowset ids of different tablets can parse to the same RowsetId.
  2. RowsetId::to_string() never round-trips to the id stored in the meta-service, so any code that compares the BE-side id string with the stored one sees a mismatch for these rowsets.
  3. These ids look like version-hole rowsets in BE logs, which is confusing when diagnosing rowset reference counts.

The [0-1] rowset is empty (0 segments, 0 rows), so we have not seen data impact, but the ids are wrong and not unique.

Solution

Either side fixes it; both are one-liners:

  1. BE: make from_hex() accept upper case, e.g. else if (i >= 'A' && i <= 'F') buf_val = i - 'A' + 10; (and ideally reject anything else instead of producing a negative nibble).
  2. FE: format with %016x (lower case), matching how the BE prints rowset ids.

Doing (1) keeps existing upper-case ids already stored in the meta-service parsing correctly.

How to Reproduce?
  1. Start a cloud-mode cluster, create any table.
  2. Look at the [0-1] rowset id of a tablet on the BE (e.g. in BE logs or via the tablet meta HTTP API): it shows as 0200000000000000ffff..., while the meta-service stores 0200000000000000 + 32 upper-case hex chars.
  3. Unit level: RowsetId id; id.init("0200000000000000ABCDEF0123456789ABCDEF0123456789"); gives mi and lo with all upper bits set (e.g. 0xffffffef0123456789-style values truncated to 64 bits) instead of 0xABCDEF0123456789.
Anything Else?

from_hex() is also used for UniqueId parsing; any other caller that can receive upper-case hex is affected the same way.

Are you willing to submit PR?
  • Yes I am willing to submit a PR!
Code of Conduct
主要言語
Java
スター
16.1k
フォーク
4k
平均マージ
2日 17時間
マージ済み PR(30日)
669

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/doris のほかの issue

apache/doris の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。