Fix distributed send that are scheduled by INSERT query

Before this patch each INSERT query re-schedule distributed send, thus
each time it resets the timer, while this is not the expected behaviour,
since in on frequent INSERT distributed sends will not be triggered at
all.

Fix this by not resetting the timer.
This commit is contained in:
Azat Khuzhin 2020-04-24 23:00:00 +03:00
parent 6bb39dafc3
commit 0157fd5d93
3 changed files with 6 additions and 3 deletions

View File

@ -41,12 +41,14 @@ bool BackgroundSchedulePoolTaskInfo::schedule()
return true;
}
bool BackgroundSchedulePoolTaskInfo::scheduleAfter(size_t ms)
bool BackgroundSchedulePoolTaskInfo::scheduleAfter(size_t ms, bool overwrite)
{
std::lock_guard lock(schedule_mutex);
if (deactivated || scheduled)
return false;
if (delayed && !overwrite)
return false;
pool.scheduleDelayedTask(shared_from_this(), ms, lock);
return true;

View File

@ -102,7 +102,8 @@ public:
bool schedule();
/// Schedule for execution after specified delay.
bool scheduleAfter(size_t ms);
/// If overwrite is set then the task will be re-scheduled (if it was already scheduled, i.e. delayed == true).
bool scheduleAfter(size_t ms, bool overwrite = true);
/// Further attempts to schedule become no-op. Will wait till the end of the current execution of the task.
void deactivate();

View File

@ -588,7 +588,7 @@ bool StorageDistributedDirectoryMonitor::scheduleAfter(size_t ms)
{
if (quit)
return false;
return task_handle->scheduleAfter(ms);
return task_handle->scheduleAfter(ms, false);
}
void StorageDistributedDirectoryMonitor::processFilesWithBatching(const std::map<UInt64, std::string> & files)