merge fixes
This commit is contained in:
parent
df46a6fc1d
commit
82ac3fab6c
54
RdbBase.cpp
54
RdbBase.cpp
@ -933,13 +933,16 @@ bool RdbBase::incorporateMerge ( ) {
|
||||
long b = m_mergeStartFileNum + m_numFilesToMerge;
|
||||
// shouldn't be called if no files merged
|
||||
if ( a == b ) {
|
||||
// unless resuming after a merge completed and we exited
|
||||
// but forgot to finish renaming the final file!!!!
|
||||
log("merge: renaming final file");
|
||||
// decrement this count
|
||||
if ( m_isMerging ) m_rdb->m_numMergesOut--;
|
||||
// exit merge mode
|
||||
m_isMerging = false;
|
||||
// return the merge token, no need for a callback
|
||||
g_msg35.releaseToken ( );
|
||||
return true;
|
||||
//return true;
|
||||
}
|
||||
// file #x is the merge file
|
||||
long x = a - 1;
|
||||
@ -1033,6 +1036,9 @@ bool RdbBase::incorporateMerge ( ) {
|
||||
|
||||
// on success unlink the files we merged and free them
|
||||
for ( long i = a ; i < b ; i++ ) {
|
||||
// incase we are starting with just the
|
||||
// linkdb0001.003.dat file and not the stuff we merged
|
||||
if ( ! m_files[i] ) continue;
|
||||
// debug msg
|
||||
log(LOG_INFO,"merge: Unlinking merged file %s (#%li).",
|
||||
m_files[i]->getFilename(),i);
|
||||
@ -1417,8 +1423,10 @@ void RdbBase::attemptMerge ( long niceness, bool forceMergeAll, bool doLog ,
|
||||
// if we are reblancing this coll then keep merges tight so all
|
||||
// the negative recs annihilate with the positive recs to free
|
||||
// up disk space since we could be short on disk space.
|
||||
if ( g_rebalance.m_inRebalanceLoop &&
|
||||
g_rebalance.m_collnum == m_collnum )
|
||||
if ( g_rebalance.m_inRebalanceLoop )
|
||||
// if might have moved on if not able to merge because
|
||||
// another was merging... so do this anyway...
|
||||
//g_rebalance.m_collnum == m_collnum )
|
||||
m_minToMerge = 2;
|
||||
|
||||
|
||||
@ -1726,11 +1734,49 @@ void RdbBase::gotTokenForMerge ( ) {
|
||||
"original %li files.",mm,n);
|
||||
// how many files to merge?
|
||||
n = mm;
|
||||
// allow a single file to continue merging if the other
|
||||
// file got merged out already
|
||||
if ( mm > 0 ) overide = true;
|
||||
|
||||
// if we've already merged and already unlinked, then the
|
||||
// process exited, now we restart with just the final
|
||||
// merge final and we need to do the rename
|
||||
if ( mm == 0 ) {
|
||||
m_isMerging = false;
|
||||
// make a fake file before us that we were merging
|
||||
// since it got nuked on disk
|
||||
//incorporateMerge();
|
||||
char fbuf[256];
|
||||
sprintf(fbuf,"%s%04li.dat",m_dbname,mergeFileId-1);
|
||||
if ( m_isTitledb )
|
||||
sprintf(fbuf,"%s%04li-%03li.dat",
|
||||
m_dbname,mergeFileId-1,id2);
|
||||
log("merge: renaming final merged file %s",fbuf);
|
||||
m_files[j]->rename(fbuf);
|
||||
sprintf(fbuf,"%s%04li.map",m_dbname,mergeFileId-1);
|
||||
//File *mf = m_maps[j]->getFile();
|
||||
m_maps[j]->rename(fbuf);
|
||||
log("merge: renaming final merged file %s",fbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
// resume the merging
|
||||
goto startMerge;
|
||||
}
|
||||
|
||||
minToMerge = m_minToMerge;
|
||||
|
||||
|
||||
// if we are reblancing this coll then keep merges tight so all
|
||||
// the negative recs annihilate with the positive recs to free
|
||||
// up disk space since we could be short on disk space.
|
||||
if ( g_rebalance.m_inRebalanceLoop )
|
||||
// if might have moved on if not able to merge because
|
||||
// another was merging... so do this anyway...
|
||||
//g_rebalance.m_collnum == m_collnum )
|
||||
minToMerge = 2;
|
||||
|
||||
|
||||
//if (m_rdb==g_tfndb.getRdb()&& g_merge.isMerging() && minToMerge <=2 )
|
||||
// minToMerge = 3;
|
||||
|
||||
@ -1779,6 +1825,8 @@ void RdbBase::gotTokenForMerge ( ) {
|
||||
//smini = -1;
|
||||
// but if we are forcing then merge ALL, except one being dumped
|
||||
if ( m_nextMergeForced ) n = numFiles;
|
||||
// or if doing relabalncing, merge them all. tight merge
|
||||
if ( g_rebalance.m_inRebalanceLoop ) n = numFiles;
|
||||
//else if ( m_isTitledb ) {
|
||||
// RdbBase *base = g_tfndb.getRdb()->m_bases[m_collnum];
|
||||
// tfndbSize = base->getDiskSpaceUsed();
|
||||
|
Loading…
x
Reference in New Issue
Block a user