Skip to content

Commit 36b035c

Browse files
XaBbl4Andrey Kravchenko
andauthored
Fix refetch header data from delta when database in backup lock (#8268)
Co-authored-by: Andrey Kravchenko <[email protected]>
1 parent e4efbdb commit 36b035c

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/jrd/pag.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,8 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite)
10551055
fb_assert(attachment);
10561056

10571057
WIN window(HEADER_PAGE_NUMBER);
1058-
header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header);
1058+
pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_header);
1059+
header_page* header = (header_page*) page;
10591060

10601061
try {
10611062

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

1169+
// If database in backup lock state...
1170+
if (!info && dbb->dbb_backup_manager->getState() != Ods::hdr_nbak_normal)
1171+
{
1172+
// refetch some data from the header, because it could be changed in the delta file
1173+
// (as initially PAG_init2 reads the header from the main file and these values
1174+
// may be outdated there)
1175+
for (const UCHAR* p = header->hdr_data; *p != HDR_end; p += 2u + p[1])
1176+
{
1177+
switch (*p)
1178+
{
1179+
case HDR_sweep_interval:
1180+
fb_assert(p[1] == sizeof(SLONG));
1181+
memcpy(&dbb->dbb_sweep_interval, p + 2, sizeof(SLONG));
1182+
break;
1183+
1184+
case HDR_repl_seq:
1185+
fb_assert(p[1] == sizeof(FB_UINT64));
1186+
memcpy(&dbb->dbb_repl_sequence, p + 2, sizeof(FB_UINT64));
1187+
break;
1188+
1189+
}
1190+
}
1191+
}
1192+
11681193
} // try
11691194
catch (const Exception&)
11701195
{

0 commit comments

Comments
 (0)