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

Method Flush

tempodb/encoding/vparquet3/wal_block.go:408–454  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

406}
407
408func (b *walBlock) Flush() (err error) {
409 if b.ids.Len() == 0 {
410 return nil
411 }
412
413 b.buffer = nil
414
415 // Flush latest meta first
416 // This mainly contains the slack-adjusted start/end times
417 metaBytes, err := json.Marshal(b.BlockMeta())
418 if err != nil {
419 return fmt.Errorf("error marshaling meta json: %w", err)
420 }
421
422 metaPath := filepath.Join(b.walPath(), backend.MetaName)
423 err = os.WriteFile(metaPath, metaBytes, 0o600)
424 if err != nil {
425 return fmt.Errorf("error writing meta json: %w", err)
426 }
427
428 // Now flush/close current writer
429 err = b.writer.Close()
430 if err != nil {
431 return fmt.Errorf("error closing writer: %w", err)
432 }
433
434 info, err := b.file.Stat()
435 if err != nil {
436 return fmt.Errorf("error getting info: %w", err)
437 }
438 sz := info.Size()
439
440 err = b.file.Close()
441 if err != nil {
442 return fmt.Errorf("error closing file: %w", err)
443 }
444
445 b.writeFlush(newWalBlockFlush(b.file.Name(), b.ids))
446 b.mtx.Lock()
447 b.flushedSize += sz
448 b.unflushedSize = 0
449 b.mtx.Unlock()
450 b.ids = common.NewIDMap[int64](0)
451
452 // Open next one
453 return b.openWriter()
454}
455
456// DataLength returns estimated size of WAL files on disk. Used for
457// 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