From b15d8e01181979d3da42afe807ffa3c3ac460dd2 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 25 Mar 2022 16:16:58 -0700 Subject: [PATCH] upgrade: Skip the pre-work if the server is already stopped. This optimization makes sense if the server is already running, but if it is already stopped, it is just prolonging the downtime. --- scripts/lib/upgrade-zulip-stage-2 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index d7a08c94c0..836a22bf09 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -322,9 +322,12 @@ else: # Our next optimization is to check whether any migrations are needed # before we start the critical section of the restart. This saves -# about 1s of downtime in a no-op upgrade. +# about 1s of downtime in a no-op upgrade. We omit this check if we +# already stopped the server above, due to low memory. migrations_needed = False -if not args.skip_migrations: +if not IS_SERVER_UP: + migrations_needed = True +elif not args.skip_migrations: logging.info("Checking for needed migrations") migrations_output = subprocess.check_output( ["./manage.py", "showmigrations"], preexec_fn=su_to_zulip, text=True