Non-deterministic pagination in /api/v2/search when rows share the same timestamp
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- clickhouse, typescript
Direção de pesquisa
Comece pela implementação do endpoint POST /api/v2/search e rastreie a consulta do ClickHouse que aplica a ordenação por Timestamp e a paginação com LIMIT/OFFSET. Verifique as configurações relevantes da tabela para _block_number e _block_offset e, em seguida, confira os testes existentes do endpoint ou adicione cobertura para timestamps iguais. Considera-se concluído quando páginas consecutivas tiverem ordenação determinística, sem linhas ignoradas ou duplicadas.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 10.1k
- Forks
- 527
- Merge médio
- 1d 20h
- PRs com merge (30d)
- 186
Preparar o ambiente
- Inclui um Dockerfile ou arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de ClickHouse/ClickStack
-
external
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
ClickHouse/ClickStack#3761 ·
Mantenedores costumam responder em até 1 dia
-
Metric chart with aggFn increase and a multi-column group-by fails: toString() gets several argumentsTalvez já em andamento @CG-5228 assumiu há 26 dias. Abertaexternal
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
ClickHouse/ClickStack#3477 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Slack notifications for inline alerts fail when the chart-explorer link passes Slack's 3000-character block limitTalvez já em andamento @Tyagiquamar assumiu há 27 dias. Abertaalerting bug external
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
ClickHouse/ClickStack#3452 ·
Mantenedores costumam responder em até 1 dia
-
check-alerts worker: 13 error spans (mongodb.create, NamespaceExists) every minute because mongoose autoCreate is still onTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertabug external Needs Feedback
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
ClickHouse/ClickStack#3308 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
count_distinct aggFn on metric tiles ignores valueExpression, always counts distinct metric ValuesTalvez já em andamento @Harshul1484 assumiu há 54 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
ClickHouse/ClickStack#2311 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de ClickHouse/ClickStack
Issues semelhantes
-
Add: GTrekkerAbertacheck:passed streams:add
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
area: ui Bug Payload OSS
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
payloadcms/payload#19839 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
fix(auth): add the email OTP verification step to Pollar loginTalvez já em andamento @akansnoro assumiu hoje. AbertaStellar Wave
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
safetrustcr/dApp-SafeTrust#584 · 10 comentários ·
Mantenedores costumam responder em até 1 dia
-
The manager preset saves launch definitions without the required file and digest pairTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
Mantenedores costumam responder em até 1 dia