nickva commented on issue #5166:
URL: https://github.com/apache/couchdb/issues/5166#issuecomment-2268219259

   In one of PR replacing the LRU dict with a map, and adding a few tests, 
@jaydoane and I stumbled on the root cause for the function clause error 
https://github.com/apache/couchdb/pull/5168#discussion_r1703072856
   
   We noticed and discussed how just plain inserts for the same Db will be 
enough to corrupt the cache and insert duplicate entries in the Tree with only 
a single entry in the Map.
   
   The reproducer eunit test looks like:
   
   ```
   t_multiple_inserts_and_close({Dbs, _, [_, _]}) ->
       {_, Map} = Cache = insert(?DB1, insert(?DB1, new())),
       meck:expect(couch_db, is_idle, 1, meck:seq([meck:val(false), 
meck:val(true)])),
       ?assertEqual(false, close(Cache)).
   ```
   
   Which results in:
   
   ```
   module 'couch_lru'
     couch_lru:112: -couch_lru_test_/0-fun-0- 
(t_multiple_inserts_and_close)...*failed*
   in function gb_trees:delete_1/2 (gb_trees.erl, line 408)
     called as delete_1(4,nil)
   in call from gb_trees:delete_1/2 (gb_trees.erl, line 409)
   in call from gb_trees:delete_1/2 (gb_trees.erl, line 412)
   in call from gb_trees:delete/2 (gb_trees.erl, line 404)
   in call from couch_lru:close_int/2 (src/couch_lru.erl, line 77)
   in call from couch_lru:t_multiple_inserts_and_close/1 (src/couch_lru.erl, 
line 227)
   in call from eunit_test:run_testfun/1 (eunit_test.erl, line 71)
   in call from eunit_proc:run_test/1 (eunit_proc.erl, line 531)
   **error:function_clause
     output:<<"">>
   ```
   
   


-- 
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]

Reply via email to