You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2018/03/27 00:22:48 UTC

[couchdb] branch master updated: Fix DB-specific compaction configuration (#1059)

This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 7bfdedb  Fix DB-specific compaction configuration (#1059)
7bfdedb is described below

commit 7bfdedbe0c89235d8b65f11127b650a2e46aa8e0
Author: Adam Kocoloski <ko...@apache.org>
AuthorDate: Thu Dec 14 15:30:41 2017 -0500

    Fix DB-specific compaction configuration (#1059)
    
    The compaction daemon was checking for custom configurations using
    shard names directly, which meant that users who defined a config for
    a specific DB would not see it take effect.
    
    This patch introduces support for custom configurations for both
    databases *and* shards. An example of a shard config would be
    
    shards/00000000-1fffffff/foo.1512750761 = [{db_fragmentation, "70%"}]
    
    We don't anticipate that to be a typical usage pattern.
---
 src/couch/src/couch_compaction_daemon.erl | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/couch/src/couch_compaction_daemon.erl b/src/couch/src/couch_compaction_daemon.erl
index 5c278aa..72d5a17 100644
--- a/src/couch/src/couch_compaction_daemon.erl
+++ b/src/couch/src/couch_compaction_daemon.erl
@@ -300,16 +300,22 @@ compact_time_left(#config{period = #period{to = {ToH, ToM} = To}}) ->
     end.
 
 
-get_db_config(DbName) ->
-    case ets:lookup(?CONFIG_ETS, DbName) of
+get_db_config(ShardName) ->
+    case ets:lookup(?CONFIG_ETS, ShardName) of
     [] ->
-        case ets:lookup(?CONFIG_ETS, <<"_default">>) of
+        DbName = mem3:dbname(ShardName),
+        case ets:lookup(?CONFIG_ETS, DbName) of
         [] ->
-            nil;
-        [{<<"_default">>, Config}] ->
+            case ets:lookup(?CONFIG_ETS, <<"_default">>) of
+            [] ->
+                nil;
+            [{<<"_default">>, Config}] ->
+                {ok, Config}
+            end;
+        [{DbName, Config}] ->
             {ok, Config}
         end;
-    [{DbName, Config}] ->
+    [{ShardName, Config}] ->
         {ok, Config}
     end.
 

-- 
To stop receiving notification emails like this one, please contact
wohali@apache.org.