Skip to content

fix: close pending iterators before closing LevelDB store#83

Merged
gmega merged 5 commits intomasterfrom
fix/auto-dispose-iterators
Feb 6, 2026
Merged

fix: close pending iterators before closing LevelDB store#83
gmega merged 5 commits intomasterfrom
fix/auto-dispose-iterators

Conversation

@gmega
Copy link
Contributor

@gmega gmega commented Feb 5, 2026

This PR adds tracking of open iterators to leveldbds so that when one attempts to close it, iterators are disposed of first. It also adds automatic disposal if iterators are completely consumed.

fixes #82

gmega added 3 commits February 5, 2026 10:43
…tors. It:

1. disposes of iterators automatically when the iterator is finished;
2. does a bit of test refactoring to reflect that.
@gmega gmega requested a review from 2-towns February 5, 2026 14:31
Comment on lines +112 to +113
iter.disposed = true
self.openIterators.excl(iter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible optimisation: check iter.disposed first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are so fast and the operation so infrequent that's probably not even worth the trouble... (plus dbIter.dispose is idemptotent)

@gmega gmega merged commit 92af582 into master Feb 6, 2026
6 checks passed
@gmega gmega deleted the fix/auto-dispose-iterators branch February 6, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LevelDB datastore crashes if one attempts to close it while there are still iterators which haven't been disposed of

2 participants