From 37bcddfa8417f66b8866b44273cf34c4fb2123d9 Mon Sep 17 00:00:00 2001 From: jm-clius Date: Wed, 30 Mar 2022 22:07:48 +0000 Subject: [PATCH] deploy: ecdde23add53b093c94b00154922cbaf68ada474 --- waku/v2/node/storage/message/waku_message_store.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/waku/v2/node/storage/message/waku_message_store.nim b/waku/v2/node/storage/message/waku_message_store.nim index b0f433588..bedc27c1f 100644 --- a/waku/v2/node/storage/message/waku_message_store.nim +++ b/waku/v2/node/storage/message/waku_message_store.nim @@ -59,9 +59,10 @@ proc deleteOldest(db: WakuMessageStore): MessageStoreResult[void] = return err(res.error) db.numMessages = db.storeCapacity + db.deleteWindow # sqlite3 DELETE does not return the number of deleted rows; Ideally we would subtract the number of actually deleted messages. We could run a separate COUNT. + info "Oldest messages deleted from DB due to overflow.", storeCapacity=db.storeCapacity, maxStore=db.storeMaxLoad, deleteWindow=db.deleteWindow when defined(debug): let numMessages = messageCount(db.database).get() # requires another SELECT query, so only run in debug mode - debug "Oldest messages deleted from DB due to overflow.", storeCapacity=db.storeCapacity, maxStore=db.storeMaxLoad, deleteWindow=db.deleteWindow, messagesLeft=numMessages + debug "Number of messages left after delete operation.", messagesLeft=numMessages # reduce the size of the DB file after the delete operation. See: https://www.sqlite.org/lang_vacuum.html let resVacuum = db.database.query("vacuum", proc(s: ptr sqlite3_stmt) = discard)