Skip to content

Implement #6413 : Data pages of newly gbak restored databases should marked as "swept" [CORE6164] #8549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Maintain "restoring" state for all Firebird processes.
  • Loading branch information
hvlad committed May 18, 2025
commit 2c97cd6c39d226ccaf8665104c6e2a23ad288220
15 changes: 7 additions & 8 deletions src/jrd/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ const ULONG DBB_gc_background = 0x20000L; // background garbage collection by
const ULONG DBB_sweep_starting = 0x40000L; // Auto-sweep is starting
const ULONG DBB_creating = 0x80000L; // Database creation is in progress
const ULONG DBB_shared = 0x100000L; // Database object is shared among connections
const ULONG DBB_restoring = 0x200000L; // Database restore is in progress

//
// dbb_ast_flags
Expand Down Expand Up @@ -311,9 +312,6 @@ class Database : public pool_alloc<type_dbb>
bool incTempCacheUsage(FB_SIZE_T size);
void decTempCacheUsage(FB_SIZE_T size);

bool getRestoring() const { return m_restoring; }
void setRestoring(bool value) { m_restoring = value; }

private:
const Firebird::string m_id;
const Firebird::RefPtr<const Firebird::Config> m_config;
Expand All @@ -324,16 +322,14 @@ class Database : public pool_alloc<type_dbb>
Firebird::Mutex m_mutex;
std::atomic<FB_UINT64> m_tempCacheUsage; // total size of in-memory temp space chunks (see TempSpace class)
const FB_UINT64 m_tempCacheLimit;
bool m_restoring;

explicit GlobalObjectHolder(const Firebird::string& id,
const Firebird::PathName& filename,
Firebird::RefPtr<const Firebird::Config> config)
: m_id(getPool(), id), m_config(config),
m_replConfig(Replication::Config::get(filename)),
m_tempCacheUsage(0),
m_tempCacheLimit(m_config->getTempCacheLimit()),
m_restoring(false)
m_tempCacheLimit(m_config->getTempCacheLimit())
{}
};

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

bool isRestoring() const
{
return dbb_gblobj_holder->getRestoring();
return dbb_flags & DBB_restoring;
}

void setRestoring(bool value)
{
dbb_gblobj_holder->setRestoring(value);
if (value)
dbb_flags |= DBB_restoring;
else
dbb_flags &= ~DBB_restoring;
}

private:
Expand Down
10 changes: 10 additions & 0 deletions src/jrd/shut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ union shutdown_data
SLONG data_long;
};

// Low byte of shutdown_data::flag used by shutdown modes, see isc_dpb_shut_XXX
// High byte used for additional flags

const SSHORT SHUT_flag_restoring = 0x0100; // database restore is in progress

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

if (flag & SHUT_flag_restoring)
dbb->setRestoring(true);

if ((flag & isc_dpb_shut_force) && !delay)
return shutdown(tdbb, flag, ast);

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

if (dbb->isRestoring())
data.data_items.flag |= SHUT_flag_restoring;

LCK_write_data(tdbb, dbb->dbb_lock, data.data_long);

{ // scope
Expand Down
Loading