| 2553 | |
| 2554 | |
| 2555 | void VIO_intermediate_gc(thread_db* tdbb, record_param* rpb, jrd_tra* transaction) |
| 2556 | { |
| 2557 | /************************************** |
| 2558 | * |
| 2559 | * V I O _ i n t e r m e d i a t e _ g c |
| 2560 | * |
| 2561 | ************************************** |
| 2562 | * |
| 2563 | * Functional description |
| 2564 | * Garbage-collect committed versions that are not needed for anyone. |
| 2565 | * This function shall be called with active RPB, and exits with inactive RPB |
| 2566 | * |
| 2567 | **************************************/ |
| 2568 | Database *dbb = tdbb->getDatabase(); |
| 2569 | Attachment* att = tdbb->getAttachment(); |
| 2570 | |
| 2571 | // If current record is not a primary version, release it and fetch primary version |
| 2572 | if (rpb->rpb_flags & rpb_chained) |
| 2573 | { |
| 2574 | CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); |
| 2575 | if (!DPM_get(tdbb, rpb, LCK_read)) |
| 2576 | return; |
| 2577 | } |
| 2578 | |
| 2579 | // If head version is being backed out - do not interfere with this process |
| 2580 | if (rpb->rpb_flags & rpb_gc_active) |
| 2581 | { |
| 2582 | CCH_RELEASE(tdbb, &rpb->getWindow(tdbb)); |
| 2583 | return; |
| 2584 | } |
| 2585 | |
| 2586 | // Read data for all versions of a record |
| 2587 | RecordStack staying, going; |
| 2588 | list_staying(tdbb, rpb, staying, LS_ACTIVE_RPB | LS_NO_RESTART); |
| 2589 | |
| 2590 | // We can only garbage collect here if there is more than one version of a record |
| 2591 | if (!staying.hasMore(1)) |
| 2592 | { |
| 2593 | clearRecordStack(staying); |
| 2594 | return; |
| 2595 | } |
| 2596 | |
| 2597 | #ifdef VIO_DEBUG |
| 2598 | VIO_trace(DEBUG_TRACE, |
| 2599 | "VIO_intermediate_gc (record_param %" SQUADFORMAT", transaction %" |
| 2600 | SQUADFORMAT")\n", |
| 2601 | rpb->rpb_number.getValue(), transaction ? transaction->tra_number : 0); |
| 2602 | |
| 2603 | VIO_trace(DEBUG_TRACE_INFO, |
| 2604 | " record %" SLONGFORMAT":%d, rpb_trans %" SQUADFORMAT |
| 2605 | ", flags %d, back %" SLONGFORMAT":%d, fragment %" SLONGFORMAT":%d\n", |
| 2606 | rpb->rpb_page, rpb->rpb_line, rpb->rpb_transaction_nr, |
| 2607 | rpb->rpb_flags, rpb->rpb_b_page, rpb->rpb_b_line, |
| 2608 | rpb->rpb_f_page, rpb->rpb_f_line); |
| 2609 | #endif |
| 2610 | |
| 2611 | TipCache* tipCache = dbb->dbb_tip_cache; |
| 2612 | tipCache->updateActiveSnapshots(tdbb, &att->att_active_snapshots); |
no test coverage detected