forked from Mirrors/privacore-open-source-search-engine
Better encapsulation of Repair
This commit is contained in:
@ -503,7 +503,7 @@ bool Collectiondb::addRdbBasesForCollRec ( CollectionRec *cr ) {
|
||||
/// this deletes the collection, not just part of a reset.
|
||||
bool Collectiondb::deleteRec2 ( collnum_t collnum ) {
|
||||
// do not allow this if in repair mode
|
||||
if ( g_repair.isRepairActive() && g_repair.m_collnum == collnum ) {
|
||||
if ( g_repair.isRepairActive() && g_repair.isRepairingColl(collnum) ) {
|
||||
log(LOG_WARN, "admin: Can not delete collection while in repair mode.");
|
||||
g_errno = EBADENGINEER;
|
||||
return true;
|
||||
@ -723,7 +723,7 @@ bool Collectiondb::setRecPtr ( collnum_t collnum , CollectionRec *cr ) {
|
||||
// . returns true with g_errno set on error
|
||||
bool Collectiondb::resetColl2( collnum_t oldCollnum, collnum_t newCollnum, bool purgeSeeds ) {
|
||||
// do not allow this if in repair mode
|
||||
if ( g_repair.isRepairActive() && g_repair.m_collnum == oldCollnum ) {
|
||||
if ( g_repair.isRepairActive() && g_repair.isRepairingColl(oldCollnum) ) {
|
||||
log(LOG_WARN, "admin: Can not delete collection while in repair mode.");
|
||||
g_errno = EBADENGINEER;
|
||||
return true;
|
||||
|
2
Rdb.cpp
2
Rdb.cpp
@ -1504,7 +1504,7 @@ bool Rdb::addList ( collnum_t collnum , RdbList *list, int32_t niceness ) {
|
||||
// they are bigger. it may add to indexdb/datedb
|
||||
if ( g_repair.isRepairActive() &&
|
||||
// but only check for collection we are repairing/rebuilding
|
||||
collnum == g_repair.m_collnum &&
|
||||
g_repair.isRepairingColl(collnum) &&
|
||||
// exception, spider status docs can be deleted from titledb
|
||||
// if user turns off 'index spider replies' before doing
|
||||
// the rebuild, when not rebuilding titledb.
|
||||
|
24
Repair.cpp
24
Repair.cpp
@ -22,12 +22,6 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
static void repairWrapper ( int fd , void *state ) ;
|
||||
static void loopWrapper ( void *state , RdbList *list , Msg5 *msg5 ) ;
|
||||
|
||||
static bool saveAllRdbs ( void *state , void (* callback)(void *state) ) ;
|
||||
static bool anyRdbNeedsSave ( ) ;
|
||||
static void doneSavingRdb ( void *state );
|
||||
|
||||
char g_repairMode = 0;
|
||||
|
||||
@ -176,13 +170,13 @@ bool Repair::init ( ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Repair::isRepairActive() {
|
||||
bool Repair::isRepairActive() const {
|
||||
return g_repairMode >= 4;
|
||||
}
|
||||
|
||||
// . call this once every second
|
||||
// . this is responsible for advancing from one g_repairMode to the next
|
||||
void repairWrapper ( int fd , void *state ) {
|
||||
void Repair::repairWrapper(int fd, void *state) {
|
||||
|
||||
g_errno = 0;
|
||||
|
||||
@ -765,7 +759,7 @@ void Repair::getNextCollToRepair ( ) {
|
||||
}
|
||||
|
||||
|
||||
void loopWrapper ( void *state , RdbList *list , Msg5 *msg5 ) {
|
||||
void Repair::loopWrapper(void *state, RdbList *list, Msg5 *msg5) {
|
||||
Repair *THIS = (Repair *)state;
|
||||
THIS->m_msg5InUse = false;
|
||||
THIS->loop(NULL);
|
||||
@ -1333,7 +1327,8 @@ bool Repair::gotScanRecList ( ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void doneWithIndexDoc ( XmlDoc *xd ) {
|
||||
|
||||
void Repair::doneWithIndexDoc(XmlDoc *xd) {
|
||||
if( g_conf.m_logTraceRepairs ) log(LOG_TRACE,"%s:%s:%d: BEGIN", __FILE__, __func__, __LINE__);
|
||||
|
||||
// preserve
|
||||
@ -1364,7 +1359,8 @@ static void doneWithIndexDoc ( XmlDoc *xd ) {
|
||||
if( g_conf.m_logTraceRepairs ) log(LOG_TRACE,"%s:%s:%d: END", __FILE__, __func__, __LINE__);
|
||||
}
|
||||
|
||||
static void doneWithIndexDocWrapper ( void *state ) {
|
||||
|
||||
void Repair::doneWithIndexDocWrapper(void *state) {
|
||||
if( g_conf.m_logTraceRepairs ) log(LOG_TRACE,"%s:%s:%d: BEGIN", __FILE__, __func__, __LINE__);
|
||||
// clean up
|
||||
doneWithIndexDoc ( (XmlDoc *)state );
|
||||
@ -1960,7 +1956,7 @@ static bool s_savingAll = false;
|
||||
// . return false if blocked, true otherwise
|
||||
// . will call the callback when all have been saved
|
||||
// . used by Repair.cpp to save all rdbs before doing repair work
|
||||
bool saveAllRdbs ( void *state , void (* callback)(void *state) ) {
|
||||
bool Repair::saveAllRdbs(void *state, void (*callback)(void *state)) {
|
||||
// only call once
|
||||
if ( s_savingAll ) {
|
||||
//log("db: Already saving all.");
|
||||
@ -1992,7 +1988,7 @@ bool saveAllRdbs ( void *state , void (* callback)(void *state) ) {
|
||||
}
|
||||
|
||||
// return false if one or more is still not closed yet
|
||||
bool anyRdbNeedsSave ( ) {
|
||||
bool Repair::anyRdbNeedsSave() {
|
||||
int32_t count = 0;
|
||||
int32_t nsr;
|
||||
Rdb **rdbs = getAllRdbs ( &nsr );
|
||||
@ -2006,7 +2002,7 @@ bool anyRdbNeedsSave ( ) {
|
||||
}
|
||||
|
||||
// returns false if waiting on some to save
|
||||
void doneSavingRdb ( void *state ) {
|
||||
void Repair::doneSavingRdb(void *state) {
|
||||
if ( ! anyRdbNeedsSave() ) return;
|
||||
// all done
|
||||
s_savingAll = false;
|
||||
|
27
Repair.h
27
Repair.h
@ -13,15 +13,27 @@
|
||||
|
||||
extern char g_repairMode;
|
||||
|
||||
class XmlDoc;
|
||||
|
||||
class Repair {
|
||||
public:
|
||||
|
||||
Repair();
|
||||
|
||||
// is the scan active and adding recs to the secondary rdbs?
|
||||
bool isRepairActive() ;
|
||||
bool isRepairActive() const;
|
||||
bool isRepairingColl(collnum_t coll) const { return m_collnum==coll; }
|
||||
|
||||
bool init();
|
||||
// if we core, call this so repair can resume where it left off
|
||||
bool save();
|
||||
|
||||
// called by Parms.cpp
|
||||
bool printRepairStatus ( SafeBuf *sb , int32_t fromIp );
|
||||
|
||||
bool linkdbRebuildPending() const { return m_rebuildLinkdb; }
|
||||
|
||||
private:
|
||||
//void allHostsReady();
|
||||
void initScan();
|
||||
void resetForNewCollection();
|
||||
@ -38,11 +50,7 @@ public:
|
||||
bool getTitleRec ( );
|
||||
bool injectTitleRec ( ) ; // TitleRec *tr );
|
||||
|
||||
// called by Pages.cpp
|
||||
bool printRepairStatus ( SafeBuf *sb , int32_t fromIp );
|
||||
|
||||
// if we core, call these so repair can resume where it left off
|
||||
bool save();
|
||||
bool load();
|
||||
|
||||
bool m_completed;
|
||||
@ -168,6 +176,15 @@ public:
|
||||
bool m_saveRepairState;
|
||||
|
||||
bool m_isRetrying;
|
||||
|
||||
static void repairWrapper(int fd, void *state);
|
||||
static void loopWrapper(void *state, RdbList *list, Msg5 *msg5);
|
||||
|
||||
static bool saveAllRdbs(void *state, void (*callback)(void *state));
|
||||
static bool anyRdbNeedsSave();
|
||||
static void doneSavingRdb(void *state);
|
||||
static void doneWithIndexDoc(XmlDoc *xd);
|
||||
static void doneWithIndexDocWrapper(void *state);
|
||||
};
|
||||
|
||||
// the global class
|
||||
|
@ -6545,7 +6545,7 @@ int32_t *XmlDoc::getSiteNumInlinks ( ) {
|
||||
// if we have already been through this
|
||||
if ( m_updatingSiteLinkInfoTags ) valid = false;
|
||||
// if rebuilding linkdb assume we have no links to sample from!
|
||||
if ( tag && m_useSecondaryRdbs && g_repair.m_rebuildLinkdb )
|
||||
if ( tag && m_useSecondaryRdbs && g_repair.linkdbRebuildPending() )
|
||||
valid = true;
|
||||
|
||||
// debug log
|
||||
|
Reference in New Issue
Block a user