This repository was archived by the owner on Mar 21, 2025. It is now read-only.
Repository navigation
K4 v1.9.6
K4 v1.9.6 PATCH
- Update to pager which is used for WAL, and SSTables to periodically sync to disk.
New pager constants
const SYNC_TICK_INTERVAL = 1 * time.Second // tick interval for syncing the file
const SYNC_ESCALATION = 1 * time.Minute // if the file is not synced in 1 minute, sync it
const WRITE_THRESHOLD = 24576 // every 24576 writes, sync the fileNew periodic sync method
func (p *Pager) startPeriodicSync() {
defer p.wg.Done()
p.once.Do(func() {
ticker := time.NewTicker(SYNC_TICK_INTERVAL)
defer ticker.Stop()
for {
select {
case <-ticker.C:
if p.writeCounter < WRITE_THRESHOLD {
if time.Since(p.lastSync) < SYNC_ESCALATION { // check if the file is synced in SYNC_ESCALATION
continue
} // if the file is not synced in SYNC_ESCALATION, sync it
}
err := p.file.Sync()
if err != nil {
return
}
p.lock.Lock()
p.writeCounter = 0
p.lastSync = time.Now()
p.lock.Unlock()
case <-p.stopSync:
return
}
}
})
}