Skip to content

Commit 2c97cd6

Browse files
committed
Maintain "restoring" state for all Firebird processes.
1 parent ab9b306 commit 2c97cd6

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/jrd/Database.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ const ULONG DBB_gc_background = 0x20000L; // background garbage collection by
230230
const ULONG DBB_sweep_starting = 0x40000L; // Auto-sweep is starting
231231
const ULONG DBB_creating = 0x80000L; // Database creation is in progress
232232
const ULONG DBB_shared = 0x100000L; // Database object is shared among connections
233+
const ULONG DBB_restoring = 0x200000L; // Database restore is in progress
233234

234235
//
235236
// dbb_ast_flags
@@ -311,9 +312,6 @@ class Database : public pool_alloc<type_dbb>
311312
bool incTempCacheUsage(FB_SIZE_T size);
312313
void decTempCacheUsage(FB_SIZE_T size);
313314

314-
bool getRestoring() const { return m_restoring; }
315-
void setRestoring(bool value) { m_restoring = value; }
316-
317315
private:
318316
const Firebird::string m_id;
319317
const Firebird::RefPtr<const Firebird::Config> m_config;
@@ -324,16 +322,14 @@ class Database : public pool_alloc<type_dbb>
324322
Firebird::Mutex m_mutex;
325323
std::atomic<FB_UINT64> m_tempCacheUsage; // total size of in-memory temp space chunks (see TempSpace class)
326324
const FB_UINT64 m_tempCacheLimit;
327-
bool m_restoring;
328325

329326
explicit GlobalObjectHolder(const Firebird::string& id,
330327
const Firebird::PathName& filename,
331328
Firebird::RefPtr<const Firebird::Config> config)
332329
: m_id(getPool(), id), m_config(config),
333330
m_replConfig(Replication::Config::get(filename)),
334331
m_tempCacheUsage(0),
335-
m_tempCacheLimit(m_config->getTempCacheLimit()),
336-
m_restoring(false)
332+
m_tempCacheLimit(m_config->getTempCacheLimit())
337333
{}
338334
};
339335

@@ -725,12 +721,15 @@ class Database : public pool_alloc<type_dbb>
725721

726722
bool isRestoring() const
727723
{
728-
return dbb_gblobj_holder->getRestoring();
724+
return dbb_flags & DBB_restoring;
729725
}
730726

731727
void setRestoring(bool value)
732728
{
733-
dbb_gblobj_holder->setRestoring(value);
729+
if (value)
730+
dbb_flags |= DBB_restoring;
731+
else
732+
dbb_flags &= ~DBB_restoring;
734733
}
735734

736735
private:

src/jrd/shut.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ union shutdown_data
5252
SLONG data_long;
5353
};
5454

55+
// Low byte of shutdown_data::flag used by shutdown modes, see isc_dpb_shut_XXX
56+
// High byte used for additional flags
57+
58+
const SSHORT SHUT_flag_restoring = 0x0100; // database restore is in progress
5559

5660
// Define this to true if you need to allow no-op behavior when requested shutdown mode
5761
// matches current. Logic of jrd8_create_database may need attention in this case too
@@ -122,6 +126,9 @@ bool SHUT_blocking_ast(thread_db* tdbb, bool ast)
122126
return false;
123127
}
124128

129+
if (flag & SHUT_flag_restoring)
130+
dbb->setRestoring(true);
131+
125132
if ((flag & isc_dpb_shut_force) && !delay)
126133
return shutdown(tdbb, flag, ast);
127134

@@ -472,6 +479,9 @@ static bool notify_shutdown(thread_db* tdbb, SSHORT flag, SSHORT delay, Sync* gu
472479
data.data_items.flag = flag;
473480
data.data_items.delay = delay;
474481

482+
if (dbb->isRestoring())
483+
data.data_items.flag |= SHUT_flag_restoring;
484+
475485
LCK_write_data(tdbb, dbb->dbb_lock, data.data_long);
476486

477487
{ // scope

0 commit comments

Comments
 (0)