|
|
@@ -6,6 +6,10 @@
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
+#ifdef HAVE_SYSTEMD
|
|
|
+#include <systemd/sd-daemon.h>
|
|
|
+#endif
|
|
|
+
|
|
|
namespace smartbotic::database {
|
|
|
|
|
|
DatabaseService::DatabaseService(Config config)
|
|
|
@@ -241,6 +245,19 @@ void DatabaseService::stop() {
|
|
|
// replay" which trips auto-readonly mode. This makes ordinary
|
|
|
// restarts pass through cleanly without needing
|
|
|
// `smartbotic-db-cli unlock`.
|
|
|
+ //
|
|
|
+ // v1.8.2 — extend systemd's stop watchdog before doing it. On Zoe
|
|
|
+ // (1.85M docs / ~5 GB tracked) the serialize takes ~70 s and the
|
|
|
+ // default TimeoutStopSec=30s SIGKILLed the process mid-write, peak
|
|
|
+ // RSS hit 11 GB (live state + uncompressed serialize buffer), and
|
|
|
+ // the new snapshot never made it to disk anyway. EXTEND_TIMEOUT_USEC
|
|
|
+ // tells systemd we're working — same protocol the recovery path
|
|
|
+ // uses during startup. Paired with TimeoutStopSec=300 in the unit
|
|
|
+ // file as the static cap.
|
|
|
+#ifdef HAVE_SYSTEMD
|
|
|
+ sd_notify(0, "EXTEND_TIMEOUT_USEC=600000000");
|
|
|
+ sd_notify(0, "STATUS=Writing final snapshot");
|
|
|
+#endif
|
|
|
try {
|
|
|
persistence_->forceSnapshot(*store_);
|
|
|
spdlog::info("Final snapshot taken on shutdown");
|