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() { func (s *Service) run() {
ticker := time.NewTicker(time.Duration(s.config.CheckInterval)) ticker := time.NewTicker(time.Duration(2 * time.Minute))
defer ticker.Stop() defer ticker.Stop()
for { for {
select { select {

View File

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