Skip to content

Commit 17d1918

Browse files
committed
Fixed bug #8988 : Parallel restore could use less active workers then it can.
1 parent 14584be commit 17d1918

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/burp/BurpTasks.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ RestoreRelationTask::RestoreRelationTask(BurpGlobals* tdgbl) : BurpTask(tdgbl),
641641
m_relation(NULL),
642642
m_lastRecord(rec_relation_data),
643643
m_writers(0),
644+
m_waiters(0),
644645
m_readDone(false),
645646
m_stop(false),
646647
m_error(false),
@@ -1008,7 +1009,7 @@ IOBuffer* RestoreRelationTask::getCleanBuffer()
10081009
void RestoreRelationTask::putDirtyBuffer(IOBuffer* buf)
10091010
{
10101011
MutexLockGuard guard(m_mutex, FB_FUNCTION);
1011-
if (m_dirtyBuffers.isEmpty())
1012+
if (m_dirtyBuffers.isEmpty() || m_waiters)
10121013
m_dirtyCond.notifyOne();
10131014
buf->unlock();
10141015
m_dirtyBuffers.push(buf);
@@ -1083,7 +1084,11 @@ IOBuffer* RestoreRelationTask::getDirtyBuffer()
10831084
MutexLockGuard guard(m_mutex, FB_FUNCTION);
10841085

10851086
while (!m_dirtyBuffers.hasData() && !m_readDone && !m_stop)
1087+
{
1088+
m_waiters++;
10861089
m_dirtyCond.wait(m_mutex);
1090+
m_waiters--;
1091+
}
10871092

10881093
if (m_stop)
10891094
return NULL;

src/burp/BurpTasks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ class RestoreRelationTask : public BurpTask
534534
rec_type m_lastRecord; // last backup record read for relation, usually rec_relation_end
535535
WriteRelationMeta m_metadata;
536536
int m_writers; // number of active writers, could be less than items allocated
537+
int m_waiters; // number of writers waiting for the dirty buffer
537538
bool m_readDone; // all records was read
538539

539540
Firebird::Mutex m_mutex;

0 commit comments

Comments
 (0)