From 8d0bf94d65b8e02140197c85012cd6978e507c37 Mon Sep 17 00:00:00 2001 From: Ilya Eremin Date: Thu, 20 Jul 2023 11:55:05 +0300 Subject: [PATCH] Backport #7233: Postfix for #5385 (CORE-5101): Fix slow database restore when Classic server mode is used --- src/jrd/shut.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/jrd/shut.cpp b/src/jrd/shut.cpp index 6b06cd8dee..3801e7055d 100644 --- a/src/jrd/shut.cpp +++ b/src/jrd/shut.cpp @@ -233,14 +233,18 @@ void SHUT_database(thread_db* tdbb, SSHORT flag, SSHORT delay, Sync* guard) bool exclusive = notify_shutdown(tdbb, flag, delay, guard); bool successful = exclusive; - // Try to get exclusive database lock periodically up to specified delay. If we - // haven't gotten it report shutdown error for weaker forms. For forced shutdown - // keep notifying until successful. - SSHORT timeout = delay ? delay - 1 : 0; - if (!exclusive) + if (exclusive) { + // Ensure we have the proper DBB_shutdown_* flags in place + shutdown(tdbb, flag, false); + } + else + { + // Try to get exclusive database lock periodically up to specified delay. If we + // haven't gotten it report shutdown error for weaker forms. For forced shutdown + // keep notifying until successful. do { if (!(dbb->dbb_ast_flags & (DBB_shut_attach | DBB_shut_tran | DBB_shut_force)))