wtclient: ensure correct disk mode for overflow queue
Before this commit, in the watchtower client's DiskOverflowQueue, there could be a situation _if no consumer was reading from the queue_ that could lead to an in-memory build up of backup tasks instead of the expected disk overflow. This commit fixes this by ensuring that if a task is read from disk, then the mode is set to disk mode to ensure that any new items are persisted to disk in this scenario. The unit tests added in the previous commit is updated here in order to show that the fix does in-fact fix the test.
This commit is contained in:
3 files changed
+28
-14
No files matched your search
@@ -529,6 +529,13 @@ func (q *DiskOverflowQueue[T]) feedMemQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
// If we did manage to fetch a task from disk, we make
|
||||
// sure to set the toDisk mode to true since we may
|
||||
// block indefinitely while trying to push the tasks to
|
||||
// the memQueue in which case we want the drainInputList
|
||||
// goroutine to write any new tasks to disk.
|
||||
q.toDisk.Store(true)
|
||||
|
||||
for i, task := range tasks {
|
||||
select {
|
||||
case q.memQueue <- task:
|
||||
|
||||
Reference in new issue
Block a user