From 694296b5639ea95300f60db7b41c0a633da2fd1f Mon Sep 17 00:00:00 2001 From: Sandeep Sukhani Date: Wed, 9 Feb 2022 13:53:01 +0530 Subject: [PATCH 1/3] add a ms instead of ns to end time of the rebound chunk interval conversion between ms and ns loses ns precision which causes us to not include all the logs --- pkg/chunkenc/memchunk.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/chunkenc/memchunk.go b/pkg/chunkenc/memchunk.go index 1c548d73c02a..86589f177b5f 100644 --- a/pkg/chunkenc/memchunk.go +++ b/pkg/chunkenc/memchunk.go @@ -912,7 +912,7 @@ func (c *MemChunk) Blocks(mintT, maxtT time.Time) []Block { // Rebound builds a smaller chunk with logs having timestamp from start and end(both inclusive) func (c *MemChunk) Rebound(start, end time.Time) (Chunk, error) { // add a nanosecond to end time because the Chunk.Iterator considers end time to be non-inclusive. - itr, err := c.Iterator(context.Background(), start, end.Add(time.Nanosecond), logproto.FORWARD, log.NewNoopPipeline().ForStream(labels.Labels{})) + itr, err := c.Iterator(context.Background(), start, end.Add(time.Millisecond), logproto.FORWARD, log.NewNoopPipeline().ForStream(labels.Labels{})) if err != nil { return nil, err } From c2ad1f72cbf2be329f065cdfdf39c0fdcff5d528 Mon Sep 17 00:00:00 2001 From: Sandeep Sukhani Date: Wed, 9 Feb 2022 14:28:46 +0530 Subject: [PATCH 2/3] improve error when failing to rebound chunk --- pkg/storage/stores/shipper/compactor/retention/retention.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/stores/shipper/compactor/retention/retention.go b/pkg/storage/stores/shipper/compactor/retention/retention.go index e66b9db5d2eb..f67ecd4748fa 100644 --- a/pkg/storage/stores/shipper/compactor/retention/retention.go +++ b/pkg/storage/stores/shipper/compactor/retention/retention.go @@ -152,7 +152,7 @@ func markforDelete(ctx context.Context, tableName string, marker MarkerStorageWr if len(nonDeletedIntervals) > 0 { wroteChunks, err := chunkRewriter.rewriteChunk(ctx, c, nonDeletedIntervals) if err != nil { - return false, false, err + return false, false, fmt.Errorf("failed to rewrite chunk %s for interval %s with error %s", c.ChunkID, nonDeletedIntervals, err) } if wroteChunks { From 9645f312ee2acec801a399dc2723a73872ed0511 Mon Sep 17 00:00:00 2001 From: Sandeep Sukhani Date: Thu, 10 Feb 2022 13:39:24 +0530 Subject: [PATCH 3/3] fix the comment --- pkg/chunkenc/memchunk.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/chunkenc/memchunk.go b/pkg/chunkenc/memchunk.go index 86589f177b5f..eccda20ab3c9 100644 --- a/pkg/chunkenc/memchunk.go +++ b/pkg/chunkenc/memchunk.go @@ -911,7 +911,7 @@ func (c *MemChunk) Blocks(mintT, maxtT time.Time) []Block { // Rebound builds a smaller chunk with logs having timestamp from start and end(both inclusive) func (c *MemChunk) Rebound(start, end time.Time) (Chunk, error) { - // add a nanosecond to end time because the Chunk.Iterator considers end time to be non-inclusive. + // add a millisecond to end time because the Chunk.Iterator considers end time to be non-inclusive. itr, err := c.Iterator(context.Background(), start, end.Add(time.Millisecond), logproto.FORWARD, log.NewNoopPipeline().ForStream(labels.Labels{})) if err != nil { return nil, err