| 248 | } |
| 249 | |
| 250 | func (s *tenantStore) determineBlockIDs(ctx context.Context, r tempodb.Reader) (nextID backend.UUID, existingBlocksToBeCompacted []backend.UUID, err error) { |
| 251 | for { |
| 252 | nextID = s.idGenerator.NewID() |
| 253 | |
| 254 | meta, compactedMeta, err := r.BlockMeta(ctx, s.tenantID, nextID) |
| 255 | if err != nil { |
| 256 | return backend.UUID{}, nil, err |
| 257 | } |
| 258 | |
| 259 | if compactedMeta != nil { |
| 260 | // This ID is already in use but does not need to be compacted again |
| 261 | continue |
| 262 | } |
| 263 | |
| 264 | if meta != nil { |
| 265 | // This ID is already in use and needs to be compacted |
| 266 | existingBlocksToBeCompacted = append(existingBlocksToBeCompacted, nextID) |
| 267 | continue |
| 268 | } |
| 269 | |
| 270 | // This block is available |
| 271 | return nextID, existingBlocksToBeCompacted, nil |
| 272 | } |
| 273 | } |