Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Wait for pending transactions on close #377

Merged
merged 1 commit into from
May 21, 2015

Conversation

benbjohnson
Copy link
Member

Overview

This pull request fixes the DB.Close() function so that it waits for any open transactions to finish before closing.

Previously a close would shutdown the DB immediately and cause a panic in any open transactions, however, no data corruption would occur.

Fixes: #341

This commit fixes the DB.Close() function so that it waits for any
open transactions to finish before closing.

db.mmaplock.RLock()
defer db.mmaplock.RUnlock()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This locking order is consistent with the rest of the library (rwlock, metalock, mmaplock). The mmaplock takes a read lock because the rwlock prevents the write lock on mmaplock.

benbjohnson added a commit that referenced this pull request May 21, 2015
Wait for pending transactions on close
@benbjohnson benbjohnson merged commit c69cb10 into boltdb:master May 21, 2015
@benbjohnson benbjohnson deleted the close-race branch May 21, 2015 15:02
rcoelho added a commit to rcoelho/bbolt that referenced this pull request Feb 13, 2018
DB.Close() actually waits for the transactions to finish now, since the PR 377.
boltdb/bolt#377
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wait to close DB if there are open transactions
1 participant