mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 16:43:21 +00:00
Merge pull request #660 from YaoZengzeng/fix
enhancement: flush the page more precisely
This commit is contained in:
commit
ccdf2f7d94
16
wal/wal.go
16
wal/wal.go
@ -631,17 +631,21 @@ func (w *WAL) log(rec []byte, final bool) error {
|
||||
copy(buf[recordHeaderSize:], part)
|
||||
p.alloc += len(part) + recordHeaderSize
|
||||
|
||||
// By definition when a record is split it means its size is bigger than
|
||||
// the page boundary so the current page would be full and needs to be flushed.
|
||||
// On contrary if we wrote a full record, we can fit more records of the batch
|
||||
// into the page before flushing it.
|
||||
if final || typ != recFull || w.page.full() {
|
||||
if err := w.flushPage(false); err != nil {
|
||||
if w.page.full() {
|
||||
if err := w.flushPage(true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
rec = rec[l:]
|
||||
}
|
||||
|
||||
// If it's the final record of the batch and the page is not empty, flush it.
|
||||
if final && w.page.alloc > 0 {
|
||||
if err := w.flushPage(false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user