File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -131,9 +131,17 @@ void ExportPartitionManifestUpdatingTask::poll()
131131 if (!cleanup_lock && has_local_entry_and_is_up_to_date)
132132 continue ;
133133
134- auto status_watch_callback = std::make_shared<Coordination::WatchCallback>([this , key](const Coordination::WatchResponse &) {
135- storage.export_merge_tree_partition_manifest_updater ->addStatusChange (key);
136- storage.export_merge_tree_partition_status_handling_task ->schedule ();
134+ std::weak_ptr<ExportPartitionManifestUpdatingTask> weak_manifest_updater = storage.export_merge_tree_partition_manifest_updater ;
135+
136+ auto status_watch_callback = std::make_shared<Coordination::WatchCallback>([weak_manifest_updater, key](const Coordination::WatchResponse &)
137+ {
138+ // / If the table is dropped but the watch is not removed, we need to prevent use after free
139+ // / below code assumes that if manifest updater is still alive, the status handling task is also alive
140+ if (auto manifest_updater = weak_manifest_updater.lock ())
141+ {
142+ manifest_updater->addStatusChange (key);
143+ manifest_updater->storage .export_merge_tree_partition_status_handling_task ->schedule ();
144+ }
137145 });
138146
139147 std::string status;
You can’t perform that action at this time.
0 commit comments