-
Type: Technical Debt
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Cache and Eviction
-
None
-
Storage Engines
The way we handle the end of the eviction loop in __wti_evict_app_assist_worker() is hard to follow and error prone.
Suggested improvements:
- We should use break instead goto err when we need to exit out of the eviction loop because that expresses the control flow – we are terminating the loop early. The err label is immediately after the loop. So the goto is functionality the same. But the goto makes the code more brittle, since it might break a future change that adds code after the loop. Also using goto err here implies that these are error conditions, when they are not.
- The function embeds a short switch statement inside the eviction for loop. Having two different levels of break statements is hard to read, and is probably why the goto err construct is used instead of breaking out of the loop. There are a small number of cases in the switch, and we won't lose readability (IMO) using if ... else .. else to handle it.