try to fix rebalancing some more.

This commit is contained in:
Matt Wells
2014-01-21 22:39:01 -08:00
parent 31cb71214c
commit 066d910934
5 changed files with 34 additions and 11 deletions

@ -1065,8 +1065,15 @@ bool Msg5::gotList2 ( ) {
// sanity check
//if ( KEYNEG(m_listPtrs[i]->getEndKey()) ) {
// char *xx=NULL;*xx=0; }
if ( KEYCMP(m_listPtrs[i]->getEndKey(),m_minEndKey,m_ks)<0 )
if ( KEYCMP(m_listPtrs[i]->getEndKey(),m_minEndKey,m_ks)<0 ) {
KEYSET(m_minEndKey,m_listPtrs[i]->getEndKey(),m_ks);
// crap, if list is all negative keys, then the
// end key seems negative too! however in this
// case RdbScan::m_endKey seems positive so
// maybe we got a negative endkey in constrain?
//if (! (m_minEndKey[0] & 0x01) )
// log("msg5: list had bad endkey");
}
}
// sanity check
//if ( KEYNEG( m_minEndKey) ) {char *xx=NULL;*xx=0; }
@ -1393,7 +1400,7 @@ bool Msg5::gotList2 ( ) {
m_waitingForMerge = false;
// thread creation failed
if ( g_conf.m_useThreads )
if ( g_conf.m_useThreads && ! g_threads.m_disabled )
log(LOG_INFO,
"net: Failed to create thread to merge lists. Doing "
"blocking merge. Hurts performance.");

@ -614,6 +614,17 @@ bool RdbBase::setFiles ( ) {
return false;
}
// everyone should start with file 0001.dat or 0000.dat
if ( m_numFiles > 0 && m_fileIds[0] > 1 ) {
log("db: missing file id 0001.dat for %s in coll %s. "
"Fix this or it'll core later. Just rename the next file "
"in line to 0001.dat/map. We probably cored at a "
"really bad time during the end of a merge process.",
m_dbname, m_coll );
char *xx=NULL; *xx=0;
}
m_dir.close();
// ensure files are sharded correctly
@ -659,6 +670,7 @@ long RdbBase::addFile ( long id , bool isNew , long mergeNum , long id2 ,
(long)MAX_RDB_FILES);
return -1;
}
// HACK: skip to avoid a OOM lockup. if RdbBase cannot dump
// its data to disk it can backlog everyone and memory will
// never get freed up.

@ -1631,9 +1631,12 @@ void RdbList::merge_r ( RdbList **lists ,
// . we don't want any positive recs to go un annhilated
// . but don't worry about this check if start and end keys are equal
//if ( m_startKey != m_endKey && (m_endKey.n0 & 0x01) == 0x00 )
if ( KEYCMP(m_startKey,m_endKey,m_ks)!=0 && KEYNEG(m_endKey) )
if ( KEYCMP(m_startKey,m_endKey,m_ks)!=0 && KEYNEG(m_endKey) ) {
log(LOG_LOGIC,"db: rdblist: merge_r: Illegal endKey for "
"merging.");
"merging. fixing.");
// make it legal so it will be read first NEXT time
KEYSUB(m_endKey,1,m_ks);
}
// do nothing if no lists passed in
if ( numLists <= 0 ) return;
// inherit the key size of what we merge

@ -3084,8 +3084,8 @@ void RdbTree::cleanTree ( ) { // char **bases ) {
if ( count == 0 ) return;
log(LOG_LOGIC,"db: Removed %li records from %s tree for invalid "
"collection number %i.",count,m_dbname,collnum);
log(LOG_LOGIC,"db: Records not actually removed for safety. Except "
"for those with negative colnums.");
//log(LOG_LOGIC,"db: Records not actually removed for safety. Except "
// "for those with negative colnums.");
static bool s_print = true;
if ( ! s_print ) return;
s_print = false;

@ -391,7 +391,7 @@ bool Rebalance::gotList ( ) {
return true;
}
char *last = NULL;
//char *last = NULL;
for ( ; ! m_list.isExhausted() ; m_list.skipCurrentRec() ) {
// get tht rec
@ -399,9 +399,9 @@ bool Rebalance::gotList ( ) {
// get shard
long shard = getShardNum ( rdbId , rec );
// save last ptr
last = rec;
//last = rec;
m_list.getKey ( rec , m_nextKey );
// debug!
//m_list.getKey ( rec , m_nextKey );
//log("rebal: checking key %s",KEYSTR(m_nextKey,ks));
// count as scanned
m_scannedCount++;
@ -445,12 +445,13 @@ bool Rebalance::gotList ( ) {
//log("rebal: done reading list");
// update nextkey
if ( last ) {
//if ( last ) {
if ( ! m_list.isEmpty() ) {
// get the last key we scanned, all "ks" bytes of it.
// because some keys are compressed and we take the
// more significant compressed out bytes from m_list.m_*
// member vars
m_list.getKey ( last , m_nextKey );
//m_list.getKey ( last , m_nextKey );
// if it is not maxxed out, then incremenet it for the
// next scan round
if ( KEYCMP ( m_nextKey , KEYMAX() , ks ) != 0 )