Skip to content

Commit d9bb2e1

Browse files
eivanov89Copilot
andauthored
Make sure that state generation is no ahead of cluster generation (#2… (ydb-platform#25043)
Co-authored-by: Copilot <[email protected]>
1 parent f1595ce commit d9bb2e1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ydb/apps/bridge_skipper_demo/bridge.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,19 @@ def __init__(self, path_to_cli: str, initial_piles: Dict[str, List[str]], use_ht
458458
# Attempt to load previous state if provided
459459
try:
460460
self._load_state()
461+
# Check that loaded state generation is not ahead of what cluster reports
462+
if self.current_state:
463+
try:
464+
pile_world_views = self.async_checker.get_health_state()
465+
latest_generation = health.get_latest_generation_pile(pile_world_views)[0]
466+
logger.info(f"Loaded state: {self.current_state}, cluster reported latest generation: {latest_generation}")
467+
if self.current_state.generation and latest_generation and self.current_state.generation > latest_generation:
468+
logger.error(f"Generation {self.current_state.generation} from state file is ahead of cluster generation {latest_generation}")
469+
self.async_checker.stop(wait=True)
470+
sys.exit(1)
471+
except Exception as e:
472+
logger.error(f"Failed to get health state or latest generation: {e}")
473+
461474
except Exception as e:
462475
logger.debug(f"Failed to load saved state: {e}")
463476

0 commit comments

Comments
 (0)