MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / VIO_garbage_collect

Function VIO_garbage_collect

src/jrd/vio.cpp:2781–2872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2779}
2780
2781bool VIO_garbage_collect(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
2782{
2783/**************************************
2784 *
2785 * V I O _ g a r b a g e _ c o l l e c t
2786 *
2787 **************************************
2788 *
2789 * Functional description
2790 * Do any garbage collection appropriate to the current
2791 * record. This is called during index creation to avoid
2792 * unnecessary work as well as false duplicate records.
2793 *
2794 * If the record complete goes away, return false.
2795 *
2796 **************************************/
2797 SET_TDBB(tdbb);
2798 Jrd::Attachment* attachment = transaction->tra_attachment;
2799
2800#ifdef VIO_DEBUG
2801 jrd_rel* relation = rpb->rpb_relation;
2802 VIO_trace(DEBUG_TRACE,
2803 "VIO_garbage_collect (rel_id %u, record_param %" QUADFORMAT"d, transaction %"
2804 SQUADFORMAT")\n",
2805 relation->rel_id, rpb->rpb_number.getValue(), transaction ? transaction->tra_number : 0);
2806
2807 VIO_trace(DEBUG_TRACE_INFO,
2808 " record %" SLONGFORMAT":%d, rpb_trans %" SQUADFORMAT
2809 ", flags %d, back %" SLONGFORMAT":%d, fragment %" SLONGFORMAT":%d\n",
2810 rpb->rpb_page, rpb->rpb_line, rpb->rpb_transaction_nr,
2811 rpb->rpb_flags, rpb->rpb_b_page, rpb->rpb_b_line,
2812 rpb->rpb_f_page, rpb->rpb_f_line);
2813#endif
2814
2815 jrd_rel::GCShared gcGuard(tdbb, rpb->rpb_relation);
2816
2817 if ((attachment->att_flags & ATT_no_cleanup) || !gcGuard.gcEnabled())
2818 return true;
2819
2820 const TraNumber oldest_snapshot = rpb->rpb_relation->isTemporary() ?
2821 attachment->att_oldest_snapshot : transaction->tra_oldest_active;
2822
2823 while (true)
2824 {
2825 if (rpb->rpb_flags & rpb_damaged)
2826 {
2827 CCH_RELEASE(tdbb, &rpb->getWindow(tdbb));
2828 return false;
2829 }
2830
2831 int state = TRA_snapshot_state(tdbb, transaction, rpb->rpb_transaction_nr);
2832
2833 // Reset (if appropriate) the garbage collect active flag to reattempt the backout
2834
2835 if (rpb->rpb_flags & rpb_gc_active)
2836 {
2837 if (checkGCActive(tdbb, rpb, state))
2838 return true;

Callers 1

handlerMethod · 0.85

Calls 12

SET_TDBBFunction · 0.85
VIO_traceFunction · 0.85
CCH_RELEASEFunction · 0.85
TRA_snapshot_stateFunction · 0.85
checkGCActiveFunction · 0.85
check_precommittedFunction · 0.85
VIO_backoutFunction · 0.85
expungeFunction · 0.85
purgeFunction · 0.85
gcEnabledMethod · 0.80
getValueMethod · 0.45
isTemporaryMethod · 0.45

Tested by

no test coverage detected