<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/couchdb.git/src/ddoc_cache/test, branch python-black</title>
<subtitle>github.com: apache/couchdb.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/'/>
<entry>
<title>Handle db deletion in couch_db:load_validation_funs</title>
<updated>2018-11-22T12:19:09+00:00</updated>
<author>
<name>ILYA Khlopotov</name>
<email>iilyak@apache.org</email>
</author>
<published>2018-09-27T10:34:01+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=d35b5c9c4a5c2820e25944de2c4fde8bc866c8c1'/>
<id>d35b5c9c4a5c2820e25944de2c4fde8bc866c8c1</id>
<content type='text'>
Previously there were quite a few problems with load_validation_funs
in the case when clustered database is deleted.

- the calls to load_validation_funs were failing with `internal_server` error [1]
- the deleted database stayed opened because:
  - the caller of the load_validation_funs (update_doc) stayed alive
  - the main_pid of the deleted database wasn't killed either
- there was an infinite loop in ddoc_cache_entry trying to recover ddoc from deleted database

The solution is:
- do not call `recover` for deleted database
- close `main_pid`
- use `erlang:error` to crash the caller

[1] - The stack trace was:
```
{database_does_not_exist,[
    {mem3_shards,load_shards_from_db,"bailey/meta",[
        {file,"src/mem3_shards.erl"},{line,394}]},
    {mem3_shards,load_shards_from_disk,1,[
        {file,"src/mem3_shards.erl"},{line,369}]},
    {mem3_shards,for_db,2,[
        {file,"src/mem3_shards.erl"},{line,54}]},
    {fabric_view_all_docs,go,5,[
        {file,"src/fabric_view_all_docs.erl"},{line,24}]},
    {ddoc_cache_entry_validation_funs,recover,1,[
        {file,"src/ddoc_cache_entry_validation_funs.erl"},{line,33}]},
    {ddoc_cache_entry,do_open,1,[
        {file,"src/ddoc_cache_entry.erl"},{line,294}]}]}
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously there were quite a few problems with load_validation_funs
in the case when clustered database is deleted.

- the calls to load_validation_funs were failing with `internal_server` error [1]
- the deleted database stayed opened because:
  - the caller of the load_validation_funs (update_doc) stayed alive
  - the main_pid of the deleted database wasn't killed either
- there was an infinite loop in ddoc_cache_entry trying to recover ddoc from deleted database

The solution is:
- do not call `recover` for deleted database
- close `main_pid`
- use `erlang:error` to crash the caller

[1] - The stack trace was:
```
{database_does_not_exist,[
    {mem3_shards,load_shards_from_db,"bailey/meta",[
        {file,"src/mem3_shards.erl"},{line,394}]},
    {mem3_shards,load_shards_from_disk,1,[
        {file,"src/mem3_shards.erl"},{line,369}]},
    {mem3_shards,for_db,2,[
        {file,"src/mem3_shards.erl"},{line,54}]},
    {fabric_view_all_docs,go,5,[
        {file,"src/fabric_view_all_docs.erl"},{line,24}]},
    {ddoc_cache_entry_validation_funs,recover,1,[
        {file,"src/ddoc_cache_entry_validation_funs.erl"},{line,33}]},
    {ddoc_cache_entry,do_open,1,[
        {file,"src/ddoc_cache_entry.erl"},{line,294}]}]}
```
</pre>
</div>
</content>
</entry>
<entry>
<title>Handle deprecated random module</title>
<updated>2017-10-05T15:40:41+00:00</updated>
<author>
<name>Nick Vatamaniuc</name>
<email>vatamane@apache.org</email>
</author>
<published>2017-10-03T06:14:22+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=75984da4b22003d0e46a9fe1001978d999387636'/>
<id>75984da4b22003d0e46a9fe1001978d999387636</id>
<content type='text'>
Use erlang release version to decide if the newer `rand` module is present or
not.

`erlang:function_exported(rand, uniform, 0)` could not be used here as it
returns false when function isn't loaded, even if module and function are both
available.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use erlang release version to decide if the newer `rand` module is present or
not.

`erlang:function_exported(rand, uniform, 0)` could not be used here as it
returns false when function isn't loaded, even if module and function are both
available.
</pre>
</div>
</content>
</entry>
<entry>
<title>Replace deprecated crypto:rand_bytes call</title>
<updated>2017-10-02T21:41:39+00:00</updated>
<author>
<name>Nick Vatamaniuc</name>
<email>vatamane@apache.org</email>
</author>
<published>2017-10-02T18:16:43+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=6bff5fb30726066e099f8214b9a220750b009ba0'/>
<id>6bff5fb30726066e099f8214b9a220750b009ba0</id>
<content type='text'>
Replaced with crypto:strong_rand_bytes
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replaced with crypto:strong_rand_bytes
</pre>
</div>
</content>
</entry>
<entry>
<title>Rewrite ddoc_cache to improve performance</title>
<updated>2017-08-01T15:32:59+00:00</updated>
<author>
<name>Paul J. Davis</name>
<email>paul.joseph.davis@gmail.com</email>
</author>
<published>2017-06-16T18:29:47+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=939761b71830ec954701f94cb6df3dab6666a794'/>
<id>939761b71830ec954701f94cb6df3dab6666a794</id>
<content type='text'>
There were a couple issues with the previous ddoc_cache implementation
that made it possible to tip over the ddoc_cache_opener process. First,
there were a lot of messages flowing through a single gen_server. And
second, the cache relied on periodically evicting entries to ensure
proper behavior in not caching an entry forever after it had changed on
disk.

The new version makes two important changes. First, entries now have an
associated process that manages the cache entry. This process will
periodically refresh the entry and if the entry has changed or no longer
exists the process will remove its entry from cache.

The second major change is that the cache entry process directly mutates
the related ets table entries so that our performance is not dependent
on the speed of ets table mutations. Using a custom entry that does no
work the cache can now sustain roughly one million operations a second
with a twenty thousand clients fighting over a cache limited to one
thousand items. In production this means that cache performance will
likely be rate limited by other factors like loading design documents
from disk.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There were a couple issues with the previous ddoc_cache implementation
that made it possible to tip over the ddoc_cache_opener process. First,
there were a lot of messages flowing through a single gen_server. And
second, the cache relied on periodically evicting entries to ensure
proper behavior in not caching an entry forever after it had changed on
disk.

The new version makes two important changes. First, entries now have an
associated process that manages the cache entry. This process will
periodically refresh the entry and if the entry has changed or no longer
exists the process will remove its entry from cache.

The second major change is that the cache entry process directly mutates
the related ets table entries so that our performance is not dependent
on the speed of ets table mutations. Using a custom entry that does no
work the cache can now sustain roughly one million operations a second
with a twenty thousand clients fighting over a cache limited to one
thousand items. In production this means that cache performance will
likely be rate limited by other factors like loading design documents
from disk.
</pre>
</div>
</content>
</entry>
</feed>
