-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Registrar not removing files when clean_removed is configured (#1…
…0747) This PR includes some changes that also did help to clean/stabilize the `text_clean_removed*` tests. Often times the tests have been stopped to early, due to races between the input file states, registrar states, and test code. After stabilizing the tests, I reliably (still needs a few runs) can trigger a data-synchronisation issue between the prospectors state and the registry. This is clearly a bug and results in state not being removed from the registry file at all. After some more testing (yay, heisenbug :/) I found a race condition between harvester shutdown, prospector state cleaning (e.g. if clean_removed is set) and registry updates. The sequence of events goes like this: ``` 1. harvester closes file 2. harvester updates prospectors local file states (marks file as finished) 3. prospector starts GC, cleaning old states 4. prospector sends 'remove state event' to the registrar (TTL=0, Finished=True). Note: state is not removed by prospector until next scan completes. 5. harvestar sends 'finished state event' to the registrar (TTL=-1, Finished=True) 6. registrar reads applies state updates: 1. change state to TTL=0, Finished=True 2. change state to TTL=-1, Finished=True 3. clean local state -> file is not removed from registry, due to TTL=-1 4. write registry ``` The change proposed changes the order the harvester cleanup propagates updates by sending the 'finished event' first before updating the prospectors state. This way we postpone the file being cleaned by the prospector and guarantee the 'finished event' and 'remove event' order (The prospector can not remove the state yet, because Finished is not set until after the 'finished event' has been published). Additions: - Add Registry class (accessed via `self.registry()`). This class is used to check/read the registry - Add InputLogs class for creating/apppending/removing log files used to drive the tests. This reduces path manipulations and reduces repetitive `with open(...) as f:` blocks. - Add LogState class. This class keeps an offset to start reading from. The offset can be advanced via `checkpoint` or is automatically advanced if `next` succeeds. Using `LogState` we can wait for a particular message to appear in the log, by ignoring old messages. This removes the need to have a count on actual messages. - Thanks to `LogState` and some minor adjustments to timings I did shave of like 10s from test_registrar.py on my machine. FB success count: - test_clean_removed: 5 - test_clean_removed_with_clean_inactive: 5
- Loading branch information
Steffen Siering
authored
Feb 18, 2019
1 parent
e1a9f54
commit 1438323
Showing
11 changed files
with
260 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.