Non-deterministic pagination in /api/v2/search when rows share the same timestamp
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- clickhouse, typescript
調査の方向性
POST /api/v2/search エンドポイントの実装から始め、Timestamp の並べ替えと LIMIT/OFFSET ページネーションを適用する ClickHouse クエリを追跡します。_block_number と _block_offset に関する関連テーブル設定を確認し、その後、エンドポイントに既存のテストがあるか確認するか、同じ Timestamp に対するテストカバレッジを追加します。連続するページで、行のスキップや重複がなく決定的な順序になることを確認できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Problem
The POST /api/v2/search endpoint (added in [hyperdxio/hyperdx#2258](https://github.com/hyperdxio/hyperdx/pull/2258)) uses LIMIT/OFFSET pagination with results ordered by Timestamp. When multiple rows share the same timestamp, pagination becomes non-deterministic -- rows near a page boundary can be duplicated or skipped across pages.
Example: If rows 90-110 all have the same Timestamp value and the client requests maxResults=100, offset=0 followed by maxResults=100, offset=100, ClickHouse arbitrarily assigns which rows fall on which page. The client may see some rows twice and miss others entirely.
Why this happens in practice
While Timestamp is DateTime64(9) (nanosecond precision), duplicate timestamps are common in real-world OTEL pipelines:
- Collector-assigned timestamps: When logs arrive at the OTEL collector without a timestamp, the collector assigns one. An entire batch receives the same timestamp.
- Limited source precision: Many language runtimes only produce microsecond or millisecond precision. The remaining digits are zero-padded, reducing the effective keyspace.
- High-throughput services: Multiple log lines from the same flush, HTTP request, or function call naturally share the same wall-clock time.
Adding search predicates reduces the likelihood (fewer matching rows means fewer ties), but the issue is still possible in any high-volume deployment.
Proposed solution
For tables with enable_block_number_column = 1 and enable_block_offset_column = 1 (which ClickStack already enables on otel_logs), add _block_number and _block_offset as tiebreaker columns in the ORDER BY clause:
ORDER BY Timestamp DESC, _block_number DESC, _block_offset DESC
LIMIT {maxResults} OFFSET {offset}
This produces a deterministic total ordering since (_block_number, _block_offset) uniquely identifies each row within a part. The additional columns should have negligible performance impact when using read_in_order.
Alternatives considered
- Cursor-based pagination (filter by
WHERE Timestamp < :last_seen): Avoids offset entirely but still non-deterministic when ties exist at the cursor boundary. Would also require a tiebreaker. - Nanosecond precision alone: Reduces probability but does not eliminate the issue, especially for collector-assigned timestamps.
- 主要言語
- TypeScript
- スター
- 10.1k
- フォーク
- 527
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 186
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ClickHouse/ClickStack のほかの issue
-
external
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ClickHouse/ClickStack#3761 ·
メンテナーはふだん 1 日以内に返信
-
Metric chart with aggFn increase and a multi-column group-by fails: toString() gets several arguments対応中かも @CG-5228 が 26 日前に担当しました。 オープンexternal
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ClickHouse/ClickStack#3477 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Slack notifications for inline alerts fail when the chart-explorer link passes Slack's 3000-character block limit対応中かも @Tyagiquamar が 27 日前に担当しました。 オープンalerting bug external
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ClickHouse/ClickStack#3452 ·
メンテナーはふだん 1 日以内に返信
-
check-alerts worker: 13 error spans (mongodb.create, NamespaceExists) every minute because mongoose autoCreate is still on再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug external Needs Feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ClickHouse/ClickStack#3308 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
count_distinct aggFn on metric tiles ignores valueExpression, always counts distinct metric Values対応中かも @Harshul1484 が 54 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ClickHouse/ClickStack#2311 ·
メンテナーはふだん 1 日以内に返信
ClickHouse/ClickStack の issue をすべて見る
似ている issue
-
Add: GTrekkerオープンcheck:passed streams:add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area: ui Bug Payload OSS
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
payloadcms/payload#19839 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
fix(auth): add the email OTP verification step to Pollar login対応中かも @akansnoro が今日担当しました。 オープンStellar Wave
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
safetrustcr/dApp-SafeTrust#584 · コメント 10 件 ·
メンテナーはふだん 1 日以内に返信
-
The manager preset saves launch definitions without the required file and digest pair対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信