Skip to content

Commit

Permalink
Fix refetch header data from delta when database in backup lock (#8268)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrey Kravchenko <andrey.kravchenko@red-soft.ru>
  • Loading branch information
XaBbl4 and Andrey Kravchenko authored Sep 30, 2024
1 parent e4efbdb commit 36b035c
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/jrd/pag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,8 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite)
fb_assert(attachment);

WIN window(HEADER_PAGE_NUMBER);
header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header);
pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_header);
header_page* header = (header_page*) page;

try {

Expand Down Expand Up @@ -1165,6 +1166,30 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite)
fb_assert(false);
}

// If database in backup lock state...
if (!info && dbb->dbb_backup_manager->getState() != Ods::hdr_nbak_normal)
{
// refetch some data from the header, because it could be changed in the delta file
// (as initially PAG_init2 reads the header from the main file and these values
// may be outdated there)
for (const UCHAR* p = header->hdr_data; *p != HDR_end; p += 2u + p[1])
{
switch (*p)
{
case HDR_sweep_interval:
fb_assert(p[1] == sizeof(SLONG));
memcpy(&dbb->dbb_sweep_interval, p + 2, sizeof(SLONG));
break;

case HDR_repl_seq:
fb_assert(p[1] == sizeof(FB_UINT64));
memcpy(&dbb->dbb_repl_sequence, p + 2, sizeof(FB_UINT64));
break;

}
}
}

} // try
catch (const Exception&)
{
Expand Down

0 comments on commit 36b035c

Please sign in to comment.