Terminate watcher if database changes

This commit is contained in:
Yves
2025-08-14 12:24:53 -07:00
parent 8a724108f1
commit d84cd182e5
2 changed files with 7 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ private:
std::condition_variable cv; std::condition_variable cv;
std::atomic<bool> should_run; std::atomic<bool> should_run;
HttpServer &server; HttpServer &server;
DatabaseInstance *watched_database;
}; };
} // namespace ui } // namespace ui
} // namespace duckdb } // namespace duckdb

View File

@@ -62,6 +62,12 @@ void Watcher::Watch() {
break; // DB went away, nothing to watch break; // DB went away, nothing to watch
} }
if (watched_database == nullptr) {
watched_database = db.get();
} else if (watched_database != db.get()) {
break; // DB changed, stop watching, will be restarted
}
duckdb::Connection con{*db}; duckdb::Connection con{*db};
auto polling_interval = GetPollingInterval(*con.context); auto polling_interval = GetPollingInterval(*con.context);
if (polling_interval == 0) { if (polling_interval == 0) {