1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 16:36:06 +00:00

fix(operations): a housekeeping pass is not started while one runs

The worker started housekeeping every 10 minutes on its control threads
whether or not the last pass had ended. A pass stuck on a host (the
cleanup of an idle upload on a host that does not answer) took one more
thread each time, and after four passes no control thread was left for
cancels and recovery. The next pass now starts only after the last one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-09 23:04:09 +03:00
parent db1db4cb32
commit d69d149d97
2 changed files with 18 additions and 1 deletions

View file

@ -60,6 +60,20 @@ class WorkerTestCase(TransactionTestCase):
def job(self, host, n):
return self.submit("test.host", {"host": host, "n": n}, f"key-h{host}-{n:04d}")
def test_a_stuck_housekeeping_pass_is_not_started_again(self):
stuck, passes = threading.Event(), []
def housekeeping():
passes.append(1)
stuck.wait(10)
with patch("operations.worker.HOUSEKEEPING_EVERY", 0), patch("operations.worker.housekeeping", housekeeping):
self.start()
self.assertTrue(wait_for(lambda: passes))
time.sleep(0.5) # ten ticks
self.assertEqual(len(passes), 1)
stuck.set()
self.assertTrue(wait_for(lambda: len(passes) > 1))
def test_a_stuck_host_takes_half_the_slots_and_one_progress_read(self):
fakes.STUCK[1] = threading.Event()
stuck = [self.job(1, n) for n in range(4)]