Skip to content

Fix LMDB NIP-45 COUNT pegging a core - #139

Open
shawnyeager wants to merge 6 commits into
barrydeen:masterfrom
shawnyeager:fix-lmdb-count-cursor
Open

shawnyeager wants to merge 6 commits into
barrydeen:masterfrom
shawnyeager:fix-lmdb-count-cursor

Conversation

@shawnyeager

Copy link
Copy Markdown

eventstore v0.17.5 CountEvents and CountEventsHLL increment the LMDB counter and then loop without calling it.next(). A NIP-45 COUNT that matches at least one event stays on that row forever, on a goroutine that ignores context, and pegs one core until the process restarts. Extra author, kind, and tag checks also run when prepareQueries left those slices nil, so some mixed filters return 0.

fiatjaf/eventstore#78 fixes both, and it is not in a tag. The LMDB sources are unchanged from v0.17.5 through v0.17.14, so this vendors v0.17.5 plus that cursor fix at third_party/eventstore and replaces the module with it. Existing LMDB databases stay compatible. Websocket COUNT calls db.CountEvents and gets the fixed counter. The admin console still walks when backendCountsSafely is false, so dropping the replace later cannot hang the console.

third_party/eventstore tests: go test -timeout 60s ./lmdb/ -run TestCountAdvancesPastMatches. Haven: go test -timeout 180s -run 'TestCountStoredEventsTerminatesOnEveryBackend|TestBackendCountsSafelyKnowsAboutLmdb'.

The branch commits are split because of upload size. Squash is appropriate. Remove third_party/eventstore and the replace once #78 is tagged.

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.

1 participant