Skip to content

Commit 8a48b33

Browse files
committed
Fix settings/current_database in system.processes for async BACKUP/RESTORE
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
1 parent 80b18a8 commit 8a48b33

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/Backups/BackupsWorker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ OperationID BackupsWorker::startMakingBackup(const ASTPtr & query, const Context
490490

491491
/// process_list_element_holder is used to make an element in ProcessList live while BACKUP is working asynchronously.
492492
auto process_list_element = context_in_use->getProcessListElement();
493+
/// Update context to preserve query information in processlist (settings, current_database)
494+
process_list_element->updateContext(context_in_use);
493495

494496
thread_pool.scheduleOrThrowOnError(
495497
[this,
@@ -853,6 +855,8 @@ OperationID BackupsWorker::startRestoring(const ASTPtr & query, ContextMutablePt
853855

854856
/// process_list_element_holder is used to make an element in ProcessList live while RESTORE is working asynchronously.
855857
auto process_list_element = context_in_use->getProcessListElement();
858+
/// Update context to preserve query information in processlist (settings, current_database)
859+
process_list_element->updateContext(context_in_use);
856860

857861
thread_pool.scheduleOrThrowOnError(
858862
[this,

src/Interpreters/ProcessList.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ class QueryStatus : public WithContext
244244
/// Same as checkTimeLimit but it never throws
245245
[[nodiscard]] bool checkTimeLimitSoft();
246246

247+
/// Use it in case of the query left in background to execute asynchronously
248+
void updateContext(ContextWeakPtr weak_context) { context = std::move(weak_context); }
249+
247250
/// Get the reference for the start of the query. Used to synchronize with other Stopwatches
248251
UInt64 getQueryCPUStartTime() { return watch.getStart(); }
249252
};

0 commit comments

Comments
 (0)