Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lru leak #2

Merged
2 commits merged into from
Nov 2, 2010
Merged

Fix lru leak #2

2 commits merged into from
Nov 2, 2010

Conversation

jlouis
Copy link
Contributor

@jlouis jlouis commented Nov 2, 2010

Hi,

This patch set fixes a (memory) leak in the LRU cache which I saw when running some Erlang Map/Reduce queries through the riakc_pb_socket interface. The commit message describes the problem and the one-line fix that plugs the leak in question.

Test case also provided.

Rather than supplying a magic constant of 2, we can pull the contant
value off of the record.
The Bucket Index in the riak_kv_lru cahce is of the ETS type
bag. Hence if we store {BKey, Key} into the table, its key will be
BKey only. Trying to call ets:delete(BucketIdx, {BKey, Key}) will then
fail to match since we are searching for {Bkey, Key} == BKey. Changing
the deletion routine to be ets:delete_object/2, fixes this problem.

The consequence is that riaks LRU does not leak memory anymore when
doing extensive Map/Reduce queries.

While here, provide a test case for the problem: Introduce a
consistency variant -- all tables must be of the same size when
full. Fill the table and test that the invariant is true. This fails
before this patch, but succeeds after.
@kevsmith
Copy link
Contributor

kevsmith commented Nov 2, 2010

Thanks for catching the leak. I've merged your fix into master.

jtuple added a commit that referenced this pull request Nov 2, 2012
Active anti-entropy is a process through which multiple replicas
periodically sync with each other and automatically repair any keys
that are missing or have divergent data. For example, a user could
delete all data from a node and Riak would automatically regenerate
the data from the other replicas.

This implementation uses hash trees / Merkle trees to perform
lightweight key exchange, with work proportional to the number of
divergent keys rather than the size of the overall keyspace.

This implementation meets several design goals:

1. The underlying hash trees are on-disk structures, and can scale to
   billions+ keys. This is in contrast to in-memory trees that require
   significant RAM to support massive keyspaces.

2. The underlying hash trees are persistent. Riak nodes can be
   restarted without fear of hash tree data being lost and needing to
   be rebuilt.

3. As new data is written to Riak, the hash trees associated with the
   various partitions are kept up-to-date. Each write in Riak triggers
   an asynchronous write to one or more hash trees. Combined with #2,
   this enables trees to be built once through a scan over existing
   data, and then maintained in real-time. In reality, trees are expired
   over time and rebuilt to ensure the hash tree and backend data stay
   in sync, and also to identify bit rot / disk failure.

4. The entire implementation is designed to be non-blocking. For
   example, a snapshot of a hash tree is generated before performing
   an exchange with other replicas, therefore allowing concurrent
   inserts of new key/hash pairs as new writes occur.

The current implementation triggers read repair for each key difference
identified through the hash exchange. This is a reasonable approach as
read repair is stable, production-tested mechanism in Riak. However,
the read repair approach leads to slower replica repair in cases where
there are a large number of key differences. This is an area for future
improvement.
@evanmcc evanmcc mentioned this pull request Dec 12, 2013
hmmr pushed a commit that referenced this pull request Apr 4, 2016
…develop

amend create_table code path to take into account WITH-props
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants