Skip to content

Commit e82fbca

Browse files
XaBbl4Andrey Kravchenko
authored andcommitted
Fix refetch header data from delta when database in backup lock (#8268)
Co-authored-by: Andrey Kravchenko <andrey.kravchenko@red-soft.ru>
1 parent 3bb2ee9 commit e82fbca

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
@@ -1100,7 +1100,8 @@ void PAG_header(thread_db* tdbb, bool info)
11001100
fb_assert(attachment);
11011101

11021102
WIN window(HEADER_PAGE_NUMBER);
1103-
header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_header);
1103+
pag* page = CCH_FETCH(tdbb, &window, LCK_read, pag_header);
1104+
header_page* header = (header_page*) page;
11041105

11051106
try {
11061107

@@ -1220,6 +1221,30 @@ void PAG_header(thread_db* tdbb, bool info)
12201221
fb_assert(false);
12211222
}
12221223

1224+
// If database in backup lock state...
1225+
if (!info && dbb->dbb_backup_manager->getState() != Ods::hdr_nbak_normal)
1226+
{
1227+
// refetch some data from the header, because it could be changed in the delta file
1228+
// (as initially PAG_init2 reads the header from the main file and these values
1229+
// may be outdated there)
1230+
for (const UCHAR* p = header->hdr_data; *p != HDR_end; p += 2u + p[1])
1231+
{
1232+
switch (*p)
1233+
{
1234+
case HDR_sweep_interval:
1235+
fb_assert(p[1] == sizeof(SLONG));
1236+
memcpy(&dbb->dbb_sweep_interval, p + 2, sizeof(SLONG));
1237+
break;
1238+
1239+
case HDR_repl_seq:
1240+
fb_assert(p[1] == sizeof(FB_UINT64));
1241+
memcpy(&dbb->dbb_repl_sequence, p + 2, sizeof(FB_UINT64));
1242+
break;
1243+
1244+
}
1245+
}
1246+
}
1247+
12231248
} // try
12241249
catch (const Exception&)
12251250
{

0 commit comments

Comments
 (0)