loki icon indicating copy to clipboard operation
loki copied to clipboard

Checksum of ChunkRef in logproto.ShardsResponse returned by Querier `IndexShards` interface is always zero when enabling `tsdb_precompute_chunks`

Open honganan opened this issue 4 months ago • 0 comments

Describe the bug

When tsdb_precompute_chunks is enabled, the Querier's IndexShards interface will marshal logproto.ShardsResponse into JSON format to return it to the frontend. However, the Checksum of ChunkRef in logproto.ShardsResponse will not be serialized due to the proto definition:

https://github.com/grafana/loki/blob/5d57a035e33dcc8c1ee25d842ee0256ef9ffe4ad/pkg/logproto/logproto.proto#L293

This causes the checksum of ChunkRefs retrieved from StoreChunks during a later execution of RangeQuery by the querier to be zero, resulting in chunkId likes: fake/310d8d8d48237abd/1929376a7fa:1929391ecd8:0 and 404 errors when fetching chunks from S3. The user experiences this as no data being found.

Querier logs:

level=error ts=2024-10-16T08:26:42.799979Z caller=batch.go:726 org_id=fake traceID=7dd3ca74b5be0014 msg="error fetching chunks" err="failed to load chunk 'fake/310d8d8d48237abd/1929376a7fa:1929391ecd8:0': failed to get s3 object: NoSuchKey: The specified key does not exist.\n\tstatus code: 404, request id: ...

To Reproduce Steps to reproduce the behavior:

  1. Started Loki (newest main branch version) with tsdb_precompute_chunks set to true in querier and index-gateway
  2. Execute a query with line filter from storage and prevent data from the ingester from affecting test results by setting a time range outside of query_ingester_within or by setting query_store_only to true.
  3. It should return no lines and querier prints above error logs.

Expected behavior

tsdb_precompute_chunks works when executing query just from storage.

Environment:

  • Infrastructure: [e.g., Kubernetes, bare-metal, laptop]
  • Deployment tool: [e.g., helm, jsonnet]

Screenshots, Promtail config, or terminal output If applicable, add any output to help explain your problem.

honganan avatar Oct 16 '24 10:10 honganan