feat(store): info message after delete (#929)

This commit is contained in:
Daniel Kaiser 2022-03-30 22:55:39 +02:00 committed by GitHub
parent a9c31b4b53
commit ecdde23add
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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)