Skip to content

Commit

Permalink
Added better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-yb committed Jan 20, 2025
1 parent 2d9749d commit 6751621
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion migtests/scripts/resumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ def run_command(command, allow_interruption=True, interrupt_after=None):
elapsed_time = time.time() - start_time
if elapsed_time > interrupt_after:
print("Interrupting the process...", flush=True)
process.terminate() # Send SIGTERM to interrupt
try:
process.terminate()
process.wait(timeout=10) # Give it 10 seconds to terminate gracefully
except subprocess.TimeoutExpired:
process.kill() # Forcefully kill if it doesn't terminate
break
time.sleep(1) # Avoid busy-waiting

Expand Down Expand Up @@ -307,7 +311,9 @@ def run_and_resume_voyager(command):
print("Process was interrupted. Preparing to resume...", flush=True)
restart_wait_time_seconds = random.randint(min_restart_wait_seconds, max_restart_wait_seconds)
print(f"Waiting {restart_wait_time_seconds // 60}m {restart_wait_time_seconds % 60}s before resuming...", flush=True)
print(f"Before waiting {restart_wait_time_seconds // 60}m {restart_wait_time_seconds % 60}s...", flush=True)
time.sleep(restart_wait_time_seconds)
print("Completed waiting. Proceeding to next attempt...", flush=True)

# Final attempt without interruption
print("\n--- Final attempt to complete the import ---")
Expand Down
2 changes: 1 addition & 1 deletion migtests/tests/resumption/pg/resumption/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ row_count:

# Resumption Settings
resumption:
max_restarts: 15
max_restarts: 20
min_interrupt_seconds: 20
max_interrupt_seconds: 45
min_restart_wait_seconds: 15
Expand Down

0 comments on commit 6751621

Please sign in to comment.