Don't mutate the Lru during close This swaps the logic to only mutate the Lru while unwinding the stack. Since the Lru is mutable now if we update while descending then we end up in an infinite loop.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/0daf2dc0 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/0daf2dc0 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/0daf2dc0 Branch: refs/heads/HACK-benchmark-COUCHDB-3191-improve-couch-lru-performance Commit: 0daf2dc055fcb8b230365f0b9a48bc066ef4c200 Parents: e114191 Author: Paul J. Davis <paul.joseph.da...@gmail.com> Authored: Mon Oct 17 14:09:30 2016 -0500 Committer: Paul J. Davis <paul.joseph.da...@gmail.com> Committed: Mon Oct 17 14:09:30 2016 -0500 ---------------------------------------------------------------------- src/couch_lru.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/0daf2dc0/src/couch_lru.erl ---------------------------------------------------------------------- diff --git a/src/couch_lru.erl b/src/couch_lru.erl index a321a80..3ecf0f6 100644 --- a/src/couch_lru.erl +++ b/src/couch_lru.erl @@ -202,12 +202,12 @@ close(Lru, Ref) -> couch_server, lru_skip ]), - NewLru = update(DbName, Lru), - close(NewLru, Next) + NewLru = close(Lru, Next), + update(DbName, NewLru) end; false -> - remove_ref(Lru, Ref), - close(Lru, Next) + NewLru = close(Lru, Next), + remove_ref(NewLru, Ref) end.