<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/couchdb.git/src/couch_expiring_cache, branch decrease-indexer-transaction-time-limit</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>Use snapshot for cache insertion</title>
<updated>2020-10-26T17:36:53+00:00</updated>
<author>
<name>Jay Doane</name>
<email>jaydoane@apache.org</email>
</author>
<published>2020-10-26T16:59:20+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=dfb27b48af05ba99c5dd47247580d7f14b7764a6'/>
<id>dfb27b48af05ba99c5dd47247580d7f14b7764a6</id>
<content type='text'>
Too many parallel attempts to insert the same keys can result in
`{erlfdb_error, 1020}`, which translates to:
"Transaction not committed due to conflict with another transaction"

This attempts to mitigate the problem by using a snapshot to read the
primary key during insertion.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Too many parallel attempts to insert the same keys can result in
`{erlfdb_error, 1020}`, which translates to:
"Transaction not committed due to conflict with another transaction"

This attempts to mitigate the problem by using a snapshot to read the
primary key during insertion.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix dialyzer warnings</title>
<updated>2020-10-26T17:36:53+00:00</updated>
<author>
<name>Jay Doane</name>
<email>jaydoane@apache.org</email>
</author>
<published>2020-10-24T06:36:52+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=4c1980e9d890b4800193de4c7bb0072a2de2ad3b'/>
<id>4c1980e9d890b4800193de4c7bb0072a2de2ad3b</id>
<content type='text'>
Fix specs to eliminate dialyzer warnings.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix specs to eliminate dialyzer warnings.
</pre>
</div>
</content>
</entry>
<entry>
<title>Improve robustness of couch expiring cache test</title>
<updated>2020-04-28T18:52:46+00:00</updated>
<author>
<name>Jay Doane</name>
<email>jaydoane@apache.org</email>
</author>
<published>2020-04-26T22:22:04+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=97227c4f3a8cdfdcf15fd4ff4a6983873595544b'/>
<id>97227c4f3a8cdfdcf15fd4ff4a6983873595544b</id>
<content type='text'>
In its current incarnation, the so-called "simple lifecycle" test is
prone to numerous failures in the CI system [1], doubtless because it's
riddled with race conditions. The original author makes many assumptions
about how quickly an (actual, unmocked) FDB instance will respond to a
request.

The primary goal is to stop failing CI builds, while other
considerations include: keeping the run time of the test as low as
possible, keeping the code coverage high, and documenting the known
races.

Specifically:
- Increase the `stale` and `expired` times by a factor of 5 to decrease
sensitivity to poor FDB performance.
- Change default timer from `erlang:system_time/1` to `os:timestamp` on
the assumption that the latter is less prone to warping [2].
- Decrease the period of the cache server reaper by half to increase
accuracy of eviction time.
- Inline and modify the `test_util:wait` code to make the timer
explicit, and emphasize that `timer:delay/1` only works with millisecond
resolution.
- Don't fail the test if it can't get a fresh lookup immediately after
insertion, but let it continue on to the next race, at least to the
point of expiration and deletion, which continue to be asserted.
- Factor `Timeout` and `Interval` to allow declarations near the other
hard-coded parameters.
- Move cache server `Opts` into `setup/0` and eliminate `start_link/0`.
- Double the overall test timeout to 20 seconds.

This has soaked for hundreds of runs on a 5 year old laptop, but the
real test is the CI system.

Should this test continue to fail CI builds, additional improvements
could include mocking the timer and/or FDB layer to eliminate the
variability of an integrated system.

[1] https://ci-couchdb.apache.org/blue/organizations/jenkins/jenkins-cm1%2FPullRequests/detail/PR-2813/10/pipeline
[2] http://erlang.org/doc/apps/erts/time_correction.html#terminology
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In its current incarnation, the so-called "simple lifecycle" test is
prone to numerous failures in the CI system [1], doubtless because it's
riddled with race conditions. The original author makes many assumptions
about how quickly an (actual, unmocked) FDB instance will respond to a
request.

The primary goal is to stop failing CI builds, while other
considerations include: keeping the run time of the test as low as
possible, keeping the code coverage high, and documenting the known
races.

Specifically:
- Increase the `stale` and `expired` times by a factor of 5 to decrease
sensitivity to poor FDB performance.
- Change default timer from `erlang:system_time/1` to `os:timestamp` on
the assumption that the latter is less prone to warping [2].
- Decrease the period of the cache server reaper by half to increase
accuracy of eviction time.
- Inline and modify the `test_util:wait` code to make the timer
explicit, and emphasize that `timer:delay/1` only works with millisecond
resolution.
- Don't fail the test if it can't get a fresh lookup immediately after
insertion, but let it continue on to the next race, at least to the
point of expiration and deletion, which continue to be asserted.
- Factor `Timeout` and `Interval` to allow declarations near the other
hard-coded parameters.
- Move cache server `Opts` into `setup/0` and eliminate `start_link/0`.
- Double the overall test timeout to 20 seconds.

This has soaked for hundreds of runs on a 5 year old laptop, but the
real test is the CI system.

Should this test continue to fail CI builds, additional improvements
could include mocking the timer and/or FDB layer to eliminate the
variability of an integrated system.

[1] https://ci-couchdb.apache.org/blue/organizations/jenkins/jenkins-cm1%2FPullRequests/detail/PR-2813/10/pipeline
[2] http://erlang.org/doc/apps/erts/time_correction.html#terminology
</pre>
</div>
</content>
</entry>
<entry>
<title>Clean up old expiry key on update insert</title>
<updated>2020-04-16T05:09:30+00:00</updated>
<author>
<name>Jay Doane</name>
<email>jaydoane@apache.org</email>
</author>
<published>2020-04-16T05:01:33+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=4098c12abeffdf89988663ec9d17544f6509256f'/>
<id>4098c12abeffdf89988663ec9d17544f6509256f</id>
<content type='text'>
When an existing key is inserted with different timestamps, the primary
key is the same but the primary value is different from the existing one.
Currently, this results in a new expiry key being inserted, but the old
one is not deleted and lingers until it is removed by the inexorable
advance of time via the `remove_expired` server messages.

This checks whether there's already primary key for the inserted key,
and if so, cleans up the existing expiry key before proceeding with the
insert.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When an existing key is inserted with different timestamps, the primary
key is the same but the primary value is different from the existing one.
Currently, this results in a new expiry key being inserted, but the old
one is not deleted and lingers until it is removed by the inexorable
advance of time via the `remove_expired` server messages.

This checks whether there's already primary key for the inserted key,
and if so, cleans up the existing expiry key before proceeding with the
insert.
</pre>
</div>
</content>
</entry>
<entry>
<title>Refactor expiring cache FDB interface</title>
<updated>2020-04-16T05:09:30+00:00</updated>
<author>
<name>Jay Doane</name>
<email>jaydoane@apache.org</email>
</author>
<published>2020-04-16T05:01:13+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=0eb1a73af424aa6403c420f8f6ebb3fe4d760f62'/>
<id>0eb1a73af424aa6403c420f8f6ebb3fe4d760f62</id>
<content type='text'>
- Rename `clear_expired_range` to `clear_range_to`
- Move `EXPIRING_CACHE` layer prefix into fabric2.hrl
- Move primary key setting to just after key &amp; value calculations
- Factor out `get_val/2` to lookup a key from FDB and unpack the value
- Factor out `prefixes/2`
- Factor out `fold_range/5`
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Rename `clear_expired_range` to `clear_range_to`
- Move `EXPIRING_CACHE` layer prefix into fabric2.hrl
- Move primary key setting to just after key &amp; value calculations
- Factor out `get_val/2` to lookup a key from FDB and unpack the value
- Factor out `prefixes/2`
- Factor out `fold_range/5`
</pre>
</div>
</content>
</entry>
<entry>
<title>Handle spurious erlfdb future</title>
<updated>2020-03-11T19:39:14+00:00</updated>
<author>
<name>Jay Doane</name>
<email>jaydoane@apache.org</email>
</author>
<published>2020-03-11T19:32:32+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=bf989eb281ae97052c7b555d68f93f46cf42aa19'/>
<id>bf989eb281ae97052c7b555d68f93f46cf42aa19</id>
<content type='text'>
Seeing log errors like the following:

CRASH REPORT Process epep_fdb_decision_cache (&lt;0.633.0&gt;) with 0 neighbors exited with reason: {bad_info,{#Ref&lt;0.2506675824.3127640065.49278&gt;,ready}} at gen_server:handle_common_reply/8(line:726) &lt;= proc_lib:init_p_do_apply/3(line:247); initial_call: {couch_expiring_cache_server,init,['Argument__1']}, ancestors: [epep_sup,&lt;0.596.0&gt;], message_queue_len: 0, messages: [], links: [&lt;0.614.0&gt;], dictionary: [{rand_seed,{#{bits =&gt; 58,jump =&gt; #Fun&lt;rand.8.15449617&gt;,next =&gt; #Fun&lt;..&gt;,...},...}},...], trap_exit: false, status: running, heap_size: 2586, stack_size: 27, reductions: 7493102

This should handle those errors, and prevent the crashes.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Seeing log errors like the following:

CRASH REPORT Process epep_fdb_decision_cache (&lt;0.633.0&gt;) with 0 neighbors exited with reason: {bad_info,{#Ref&lt;0.2506675824.3127640065.49278&gt;,ready}} at gen_server:handle_common_reply/8(line:726) &lt;= proc_lib:init_p_do_apply/3(line:247); initial_call: {couch_expiring_cache_server,init,['Argument__1']}, ancestors: [epep_sup,&lt;0.596.0&gt;], message_queue_len: 0, messages: [], links: [&lt;0.614.0&gt;], dictionary: [{rand_seed,{#{bits =&gt; 58,jump =&gt; #Fun&lt;rand.8.15449617&gt;,next =&gt; #Fun&lt;..&gt;,...},...}},...], trap_exit: false, status: running, heap_size: 2586, stack_size: 27, reductions: 7493102

This should handle those errors, and prevent the crashes.
</pre>
</div>
</content>
</entry>
<entry>
<title>Delete unused ets table creation</title>
<updated>2020-03-02T18:26:22+00:00</updated>
<author>
<name>Jay Doane</name>
<email>jaydoane@apache.org</email>
</author>
<published>2020-01-29T03:06:07+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=2fb578df535e308e72b0b3d098b7ec330a403afb'/>
<id>2fb578df535e308e72b0b3d098b7ec330a403afb</id>
<content type='text'>
This ets table was a holdover from when couch_expiring_cache was a non-
library OTP application. It is unused, and would prevent multiple users
of the library in the same project.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This ets table was a holdover from when couch_expiring_cache was a non-
library OTP application. It is unused, and would prevent multiple users
of the library in the same project.
</pre>
</div>
</content>
</entry>
<entry>
<title>Expiring cache</title>
<updated>2020-03-02T18:26:22+00:00</updated>
<author>
<name>Jay Doane</name>
<email>jaydoane@apache.org</email>
</author>
<published>2019-12-11T00:49:38+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/couchdb.git/commit/?id=4e8b200406baf8514a195e1b59df41bbf23bea57'/>
<id>4e8b200406baf8514a195e1b59df41bbf23bea57</id>
<content type='text'>
This is a library for creating an FDB backed key value cache, where
each entry has a `stale` and `expires` time associated with it. Once
the current time exceeds the `expires` time, the entry is automatically
removed. The `stale` time can be used to indicate that a refresh is
necessary, while still returning a non-expired value. It is potentially
useful for implementing e.g. caches to external systems of record, such
as OAuth 2.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a library for creating an FDB backed key value cache, where
each entry has a `stale` and `expires` time associated with it. Once
the current time exceeds the `expires` time, the entry is automatically
removed. The `stale` time can be used to indicate that a refresh is
necessary, while still returning a non-expired value. It is potentially
useful for implementing e.g. caches to external systems of record, such
as OAuth 2.
</pre>
</div>
</content>
</entry>
</feed>
