quadstorejs / quadstore

A LevelDB-backed graph database for JS runtimes (Node.js, Deno, browsers, ...) supporting SPARQL queries and the RDF/JS interface.
https://github.com/quadstorejs/quadstore
MIT License
202 stars 14 forks source link

AsyncIterator _end race condition workaround #125

Closed gsvarovsky closed 3 years ago

gsvarovsky commented 3 years ago

This is a workaround for a race condition in AsyncIterator, which arises during my unit tests, in which _end is called on the LevelIterator twice, asynchronously from:

The outcome in node-quadstore is that the LevelDown AbstractIterator is ended twice, which throws the second time.

I have yet to reproduce this problem either in node-quadstore or in base AsyncIterator.

cc @RubenVerborgh, just in case the cause is obvious.

RubenVerborgh commented 3 years ago

Is it a problem in AsyncIterator? Then we likely want to fix it over there.

RubenVerborgh commented 3 years ago

On mobile now, but looks like a problem in this library (and hence your fix seems correct). I believe the _end method should be prepared to be called multiple times; but it’s probably best to document that in AsyncIterator.

jacoscaz commented 3 years ago

@gsvarovsky looks like your workaround is not a workaround but an actual fix! Thank you for this and thank you @RubenVerborgh for reviewing, I'll merge and release in the next few days!

jacoscaz commented 3 years ago

Released in v7.2.1!