feat: wip

db/shards_persisting_chaos_testing
devanbenz 2025-06-13 12:24:02 -05:00
parent 1a7b8983bf
commit fac5b363c5
2 changed files with 22 additions and 17 deletions

View File

@ -103,7 +103,7 @@ func (s *Service) WithLogger(log *zap.Logger) {
}
func (s *Service) run() {
ticker := time.NewTicker(time.Duration(s.config.CheckInterval))
ticker := time.NewTicker(time.Duration(2 * time.Minute))
defer ticker.Stop()
for {
select {

View File

@ -1075,12 +1075,7 @@ func (p *Partition) compact() {
p.currentCompactionN++
p.logger.Warn("currentCompaction INCREASED", zap.Int("currentCompactionN", p.currentCompactionN))
go func() {
if p.shouldChaosKill() {
p.logger.Warn("CHAOS: Randomly killing log file compaction goroutine",
zap.String("file", logFile.Path()), zap.Int("currentCompactionN", p.currentCompactionN))
return
}
p.compactLogFile(logFile)
defer func() {
p.mu.Lock()
p.currentCompactionN--
p.logger.Warn("currentCompaction DECREASED", zap.Int("currentCompactionN", p.currentCompactionN))
@ -1088,6 +1083,14 @@ func (p *Partition) compact() {
p.mu.Unlock()
p.Compact()
}()
if p.shouldChaosKill() {
p.logger.Warn("CHAOS: Randomly killing log file compaction goroutine",
zap.String("file", logFile.Path()), zap.Int("currentCompactionN", p.currentCompactionN))
return
}
p.compactLogFile(logFile)
}()
}
}
@ -1121,13 +1124,7 @@ func (p *Partition) compact() {
p.currentCompactionN++
p.logger.Warn("currentCompaction INCREASED", zap.Int("currentCompactionN", p.currentCompactionN))
go func() {
if p.shouldChaosKill() {
p.logger.Warn("CHAOS: Randomly killing log file compaction goroutine", zap.Int("currentCompactionN", p.currentCompactionN))
return
}
// Compact to a new level.
p.compactToLevel(files, level+1, interrupt)
defer func() {
// Ensure compaction lock for the level is released.
p.mu.Lock()
p.levelCompacting[level] = false
@ -1138,6 +1135,14 @@ func (p *Partition) compact() {
// Check for new compactions
p.Compact()
}()
if p.shouldChaosKill() {
p.logger.Warn("CHAOS: Randomly killing log file compaction goroutine", zap.Int("currentCompactionN", p.currentCompactionN))
return
}
// Compact to a new level.
p.compactToLevel(files, level+1, interrupt)
}()
}(files, level)
}
}