MCPcopy
hub / github.com/grafana/tempo / Flush

Method Flush

tempodb/encoding/vparquet4/wal_block.go:419–465  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

417}
418
419func (b *walBlock) Flush() (err error) {
420 if b.ids.Len() == 0 {
421 return nil
422 }
423
424 b.buffer = nil
425
426 // Flush latest meta first
427 // This mainly contains the slack-adjusted start/end times
428 metaBytes, err := json.Marshal(b.BlockMeta())
429 if err != nil {
430 return fmt.Errorf("error marshaling meta json: %w", err)
431 }
432
433 metaPath := filepath.Join(b.walPath(), backend.MetaName)
434 err = os.WriteFile(metaPath, metaBytes, 0o600)
435 if err != nil {
436 return fmt.Errorf("error writing meta json: %w", err)
437 }
438
439 // Now flush/close current writer
440 err = b.writer.Close()
441 if err != nil {
442 return fmt.Errorf("error closing writer: %w", err)
443 }
444
445 info, err := b.file.Stat()
446 if err != nil {
447 return fmt.Errorf("error getting info: %w", err)
448 }
449 sz := info.Size()
450
451 err = b.file.Close()
452 if err != nil {
453 return fmt.Errorf("error closing file: %w", err)
454 }
455
456 b.writeFlush(newWalBlockFlush(b.file.Name(), b.ids))
457 b.mtx.Lock()
458 b.flushedSize += sz
459 b.unflushedSize = 0
460 b.mtx.Unlock()
461 b.ids = common.NewIDMap[int64](b.ids.Len()) // Recreate new id map with same expected size
462
463 // Open next one
464 return b.openWriter()
465}
466
467// DataLength returns estimated size of WAL files on disk. Used for
468// cutting WAL files by max size.

Callers

nothing calls this directly

Calls 11

BlockMetaMethod · 0.95
walPathMethod · 0.95
writeFlushMethod · 0.95
openWriterMethod · 0.95
newWalBlockFlushFunction · 0.70
LenMethod · 0.65
MarshalMethod · 0.65
JoinMethod · 0.65
CloseMethod · 0.65
SizeMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected