Skip to content

Commit ddd5d04

Browse files
committed
Make validation detect and fix data page error when DP marked as secondary contains primary record version(s).
See CORE-5459. So far i can't reproduce the corruption thus ticket is not resolved.
1 parent 94818ef commit ddd5d04

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/jrd/validation.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,8 @@ const Validation::MSG_ENTRY Validation::vdr_msg_table[VAL_MAX_ERROR] =
847847
{true, fb_info_pip_errors, "Data page %" ULONGFORMAT" marked as free in PIP (%" ULONGFORMAT":%" ULONGFORMAT")"},
848848
{true, isc_info_ppage_errors, "Data page %" ULONGFORMAT" is not in PP (%" ULONGFORMAT"). Slot (%d) is not found"},
849849
{true, isc_info_ppage_errors, "Data page %" ULONGFORMAT" is not in PP (%" ULONGFORMAT"). Slot (%d) has value %" ULONGFORMAT},
850-
{true, isc_info_ppage_errors, "Pointer page is not found for data page %" ULONGFORMAT". dpg_sequence (%" ULONGFORMAT") is invalid"}
850+
{true, isc_info_ppage_errors, "Pointer page is not found for data page %" ULONGFORMAT". dpg_sequence (%" ULONGFORMAT") is invalid"},
851+
{true, isc_info_dpage_errors, "Data page %" ULONGFORMAT" {sequence %" ULONGFORMAT"} marked as secondary but contains primary record versions"}
851852
};
852853

853854
Validation::Validation(thread_db* tdbb, UtilSvc* uSvc) :
@@ -1751,6 +1752,8 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number,
17511752
const UCHAR* const end_page = (UCHAR*) page + dbb->dbb_page_size;
17521753
const data_page::dpg_repeat* const end = page->dpg_rpt + page->dpg_count;
17531754
RecordNumber number((SINT64)sequence * dbb->dbb_max_records);
1755+
int primary_versions = 0;
1756+
bool marked = false;
17541757

17551758
for (const data_page::dpg_repeat* line = page->dpg_rpt; line < end; line++, number.increment())
17561759
{
@@ -1798,6 +1801,8 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number,
17981801
if (state == tra_committed || state == tra_limbo)
17991802
RBM_SET(vdr_tdbb->getDefaultPool(), &vdr_rel_records, number.getValue());
18001803
}
1804+
1805+
primary_versions++;
18011806
}
18021807

18031808
#ifdef DEBUG_VAL_VERBOSE
@@ -1820,7 +1825,11 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number,
18201825

18211826
if ((result == rtn_corrupt) && (vdr_flags & VDR_repair))
18221827
{
1823-
CCH_MARK(vdr_tdbb, &window);
1828+
if (!marked)
1829+
{
1830+
CCH_MARK(vdr_tdbb, &window);
1831+
marked = true;
1832+
}
18241833
header->rhd_flags |= rhd_damaged;
18251834
vdr_fixed++;
18261835
}
@@ -1832,6 +1841,22 @@ Validation::RTN Validation::walk_data_page(jrd_rel* relation, ULONG page_number,
18321841
#endif
18331842
}
18341843

1844+
if (primary_versions && (dp_flags & dpg_secondary))
1845+
{
1846+
corrupt(VAL_DATA_PAGE_SEC_PRI, relation, page_number, sequence);
1847+
if (vdr_flags & VDR_update)
1848+
{
1849+
if (!marked)
1850+
{
1851+
CCH_MARK(vdr_tdbb, &window);
1852+
marked = true;
1853+
}
1854+
page->dpg_header.pag_flags &= ~dpg_secondary;
1855+
pp_bits &= ~ppg_dp_secondary;
1856+
vdr_fixed++;
1857+
}
1858+
}
1859+
18351860
release_page(&window);
18361861

18371862
#ifdef DEBUG_VAL_VERBOSE

src/jrd/validation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ class Validation
119119
VAL_DATA_PAGE_SLOT_NOT_FOUND= 36,
120120
VAL_DATA_PAGE_SLOT_BAD_VAL = 37,
121121
VAL_DATA_PAGE_HASNO_PP = 38,
122+
VAL_DATA_PAGE_SEC_PRI = 39,
122123

123-
VAL_MAX_ERROR = 39
124+
VAL_MAX_ERROR = 40
124125
};
125126

126127
struct MSG_ENTRY

0 commit comments

Comments
 (0)