From 3b7758a4f2a101dc27720b6d814e9df48b8025e9 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 6 Oct 2020 10:36:57 -0600 Subject: [PATCH] Add comment explaining rbf.DB.checkpoint() args --- rbf/db.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rbf/db.go b/rbf/db.go index 970c66b0c..f60b12081 100644 --- a/rbf/db.go +++ b/rbf/db.go @@ -219,8 +219,12 @@ func (db *DB) Checkpoint() error { // checkpoint moves WAL segments to the main DB file. // -// Note that mu should db.mu when called through the external API but it -// can be &nopLocker if called under lock. +// Note that mu should db.mu when called through DB.Checkpoint() but it +// can be &nopLocker if called under lock. The external API will be used +// to periodically checkpoint outside of a transaction and the locking +// must be used only in the beginning (to obtain the segment list) and at +// the end (when removing old segments from the list). If the entire function +// were to obtain a lock then it would block all new read & write transactions. func (db *DB) checkpoint(exclusive bool, mu sync.Locker) error { // Obtain a snapshot of WAL segments at the start. mu.Lock()