fiatjaf / eventstore

an abstraction layer over databases for nostr events
The Unlicense
26 stars 15 forks source link

prevent deadlocking when `QueryEvents()` is not read fully #12

Closed fiatjaf closed 1 month ago

fiatjaf commented 6 months ago

this could happen in relay queries that exit before EOSE.

the channel inside QueryEvents() of every backend will just halt since no one is reading from it.

fiatjaf commented 6 months ago

please take a look @mattn, is this the wrong approach?

fiatjaf commented 6 months ago

Actually this has happened in the real world not because of a broken connection, but because @pablof7z was calling .QueryEvents() manually and then not reading the returned channel until completion.

I still think it's a bug on this library to not handle that case correctly, but maybe we shouldn't fix and we should just say "beware: channels must be read until completion"?

I guess fixing is better if it's not incredibly inefficient.

fiatjaf commented 2 months ago

This PR is so old I had forgotten about it. I think it's still applies, right?

mattn commented 1 month ago

LGTM

mattn commented 1 month ago

Thank you