nickva opened a new pull request, #5169:
URL: https://github.com/apache/couchdb/pull/5169
Previously, calling insert multiple times for the same db, created multiple
tree entries and only one map entry. Fix this but ensuring the cache can never
be inconsistent as a result of performing any number of inserts or updates.
This should fix the function clause described in #5168. A detailed example
on how this double insert leads to the function clause follows:
* Calling insert twice for database `Db` might make the cache look
something like this:
```
{gb_tree([{100, Db}, ..., {200, Db}, ...]), #{..., Db => 200, ...}}
```
* During traversal when closing, if the first entry (100) is idle, we'd try
to update it (bump it). But when bumping, we'd pick out `200` as the key to
delete from the `Tree`, instead of 100! So we'd delete 200 and may bump to some
higher number like `300`.
* To recap, at this point the iterator would be stopped at `{100, Db}` with
the rest of iterator tree looking like `[..., {200, Db}, ...]` and the `Tree`
accumulator will look something like `[{100, Db}, ..., {300, Db}, ...]`.
* The iterator continues traversing and reaches the `{200, Db}` entry. If
it's idle, it will try to delete it from the `Tree`. But the tree, doesn't have
a `200` entry any longer, it has a `300` which leads to a function clause error
as seen in #5168.
While at it, make sure we get complete 100% test coverage, add a previously
failing test case, even though it doesn't really apply after the the fix, it's
mostly for historical reasons.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]