| 459 | } |
| 460 | |
| 461 | func (p *Poller) pollBlock( |
| 462 | ctx context.Context, |
| 463 | tenantID string, |
| 464 | blockID uuid.UUID, |
| 465 | compacted bool, |
| 466 | ) (*backend.BlockMeta, *backend.CompactedBlockMeta, error) { |
| 467 | derivedCtx, span := tracer.Start(ctx, "Poller.pollBlock") |
| 468 | defer span.End() |
| 469 | var err error |
| 470 | |
| 471 | span.SetAttributes(attribute.String("tenant", tenantID)) |
| 472 | span.SetAttributes(attribute.String("block", blockID.String())) |
| 473 | |
| 474 | var blockMeta *backend.BlockMeta |
| 475 | var compactedBlockMeta *backend.CompactedBlockMeta |
| 476 | |
| 477 | if !compacted && p.cfg.SkipNoCompactBlocks { |
| 478 | noCompact, flagErr := p.reader.HasNoCompactFlag(derivedCtx, blockID, tenantID) |
| 479 | if flagErr != nil { |
| 480 | return nil, nil, fmt.Errorf("failed to check nocompact flag: %w", flagErr) |
| 481 | } |
| 482 | if noCompact { |
| 483 | return nil, nil, nil |
| 484 | } |
| 485 | } |
| 486 | if !compacted { |
| 487 | blockMeta, err = p.reader.BlockMeta(derivedCtx, blockID, tenantID) |
| 488 | } |
| 489 | // if the normal meta doesn't exist maybe it's compacted. |
| 490 | if errors.Is(err, backend.ErrDoesNotExist) || compacted { |
| 491 | blockMeta = nil |
| 492 | compactedBlockMeta, err = p.compactor.CompactedBlockMeta(blockID, tenantID) |
| 493 | } |
| 494 | |
| 495 | // blocks in intermediate states may not have a compacted or normal block meta. |
| 496 | // this is not necessarily an error, just bail out |
| 497 | if errors.Is(err, backend.ErrDoesNotExist) { |
| 498 | return nil, nil, nil |
| 499 | } |
| 500 | |
| 501 | if err != nil { |
| 502 | return nil, nil, err |
| 503 | } |
| 504 | |
| 505 | return blockMeta, compactedBlockMeta, nil |
| 506 | } |
| 507 | |
| 508 | // tenantIndexBuilder returns true if this poller owns this tenant |
| 509 | func (p *Poller) tenantIndexBuilder(tenant string) bool { |