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

Class SweepParameter

src/jrd/tra.cpp:2712–2784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2710
2711namespace {
2712 class SweepParameter : public GlobalStorage
2713 {
2714 public:
2715 SweepParameter(Database* d)
2716 : dbb(d)
2717 { }
2718
2719 static void runSweep(SweepParameter* par)
2720 {
2721 FbLocalStatus status;
2722 PathName dbName(par->dbb->dbb_database_name);
2723
2724 // temporarily disable automatic sweep for encrypted DBs with remote key
2725 ICryptKeyCallback* cryptCallback(nullptr);
2726#ifdef NEVERDEF
2727 ICryptKeyCallback* cryptCallback(par->dbb->dbb_callback);
2728 // small (~ 1/2 sec in 2020) delay to debug unload at problematic moment
2729 long long x = 0x10000000;
2730 while (--x > 0);
2731#endif
2732
2733 // reference is needed to guarantee that provider exists
2734 // between semaphore release and attach database
2735 AutoPlugin<JProvider> prov(JProvider::getInstance());
2736 if (cryptCallback)
2737 {
2738 prov->setDbCryptCallback(&status, cryptCallback);
2739 status.check();
2740 }
2741
2742 AutoDispose<IXpbBuilder> dpb(UtilInterfacePtr()->getXpbBuilder(&status, IXpbBuilder::DPB, nullptr, 0));
2743 status.check();
2744 dpb->insertString(&status, isc_dpb_user_name, "sweeper");
2745 status.check();
2746 UCHAR byte = isc_dpb_records;
2747 dpb->insertBytes(&status, isc_dpb_sweep, &byte, 1);
2748 status.check();
2749 const UCHAR* dpbBytes = dpb->getBuffer(&status);
2750 status.check();
2751 unsigned dpbLen = dpb->getBufferLength(&status);
2752 status.check();
2753
2754 AutoRelease<IAttachment> att(prov->attachDatabase(&status, dbName.c_str(), dpbLen, dpbBytes));
2755 if (fb_utils::containsErrorCode(status->getErrors(), isc_sweep_unable_to_run))
2756 return;
2757
2758 status.check();
2759 }
2760
2761 void exceptionHandler(const Exception& ex, ThreadFinishSync<SweepParameter*>::ThreadRoutine*)
2762 {
2763 FbLocalStatus st;
2764 ex.stuffException(&st);
2765 if (st->getErrors()[1] != isc_att_shutdown)
2766 iscLogException("Automatic sweep error", ex);
2767
2768 if (dbb)
2769 {

Callers 1

start_sweeperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected