mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 10:40:38 +01:00
Avoid not necessary allocations from pool when performing FK check.
It fixes most significant source of contention in SuperServer when FK index is created by many parallel workers, as discussed in #8071
This commit is contained in:
parent
6ee20153cd
commit
717d3e2afb
@ -1681,7 +1681,9 @@ static idx_e check_duplicates(thread_db* tdbb,
|
|||||||
index_desc* insertion_idx = insertion->iib_descriptor;
|
index_desc* insertion_idx = insertion->iib_descriptor;
|
||||||
record_param rpb;
|
record_param rpb;
|
||||||
rpb.rpb_relation = insertion->iib_relation;
|
rpb.rpb_relation = insertion->iib_relation;
|
||||||
rpb.rpb_record = NULL;
|
|
||||||
|
AutoTempRecord gc_record(VIO_gc_record(tdbb, rpb.rpb_relation));
|
||||||
|
rpb.rpb_record = gc_record;
|
||||||
|
|
||||||
jrd_rel* const relation_1 = insertion->iib_relation;
|
jrd_rel* const relation_1 = insertion->iib_relation;
|
||||||
RecordBitmap::Accessor accessor(insertion->iib_duplicates);
|
RecordBitmap::Accessor accessor(insertion->iib_duplicates);
|
||||||
@ -1754,7 +1756,8 @@ static idx_e check_duplicates(thread_db* tdbb,
|
|||||||
}
|
}
|
||||||
} while (accessor.getNext());
|
} while (accessor.getNext());
|
||||||
|
|
||||||
delete rpb.rpb_record;
|
if (rpb.rpb_record != gc_record)
|
||||||
|
delete rpb.rpb_record;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1952,12 +1955,13 @@ static idx_e check_partner_index(thread_db* tdbb,
|
|||||||
if ((idx->idx_flags & idx_descending) != (partner_idx.idx_flags & idx_descending))
|
if ((idx->idx_flags & idx_descending) != (partner_idx.idx_flags & idx_descending))
|
||||||
BTR_complement_key(key);
|
BTR_complement_key(key);
|
||||||
|
|
||||||
RecordBitmap* bitmap = NULL;
|
RecordBitmap bm(*tdbb->getDefaultPool());
|
||||||
|
RecordBitmap* bitmap = &bm;
|
||||||
BTR_evaluate(tdbb, &retrieval, &bitmap, NULL);
|
BTR_evaluate(tdbb, &retrieval, &bitmap, NULL);
|
||||||
|
|
||||||
// if there is a bitmap, it means duplicates were found
|
// if there is a bitmap, it means duplicates were found
|
||||||
|
|
||||||
if (bitmap)
|
if (bitmap->getFirst())
|
||||||
{
|
{
|
||||||
index_insertion insertion;
|
index_insertion insertion;
|
||||||
insertion.iib_descriptor = &partner_idx;
|
insertion.iib_descriptor = &partner_idx;
|
||||||
@ -1972,7 +1976,6 @@ static idx_e check_partner_index(thread_db* tdbb,
|
|||||||
result = result ? idx_e_foreign_references_present : idx_e_ok;
|
result = result ? idx_e_foreign_references_present : idx_e_ok;
|
||||||
if (idx->idx_flags & idx_foreign)
|
if (idx->idx_flags & idx_foreign)
|
||||||
result = result ? idx_e_ok : idx_e_foreign_target_doesnt_exist;
|
result = result ? idx_e_ok : idx_e_foreign_target_doesnt_exist;
|
||||||
delete bitmap;
|
|
||||||
}
|
}
|
||||||
else if (idx->idx_flags & idx_foreign)
|
else if (idx->idx_flags & idx_foreign)
|
||||||
result = idx_e_foreign_target_doesnt_exist;
|
result = idx_e_foreign_target_doesnt_exist;
|
||||||
|
Loading…
Reference in New Issue
Block a user