anchor.diff:      true;
   requires_couch_restart(_Other) ->
       false.
  +
  +-ifdef(EUNIT).
  +decide_autocompaction_config_changes_test() ->
  +    Cfg1 = [[{autocompaction,
  +              [{'_vclock',[{'n_0@192.168.2.168',{1,63481318861}}]},
  +               {parallel_db_and_view_compaction,true},
  +               {database_fragmentation_threshold,66},
  +               {view_fragmentation_threshold,80}]},
  +             {buckets,
  +              [{'_vclock',
  +                [{'n_0@127.0.0.1',{3,63481314227}},
  +                 {'n_0@192.168.2.168',{14,63481323468}}]},
  +               {configs,
  +                [{"mcd",
  +                  [{ram_quota,314572800},
  +                   {auth_type,sasl},
  +                   {sasl_password,[]},
  +                   {type,memcached},
  +                   {num_vbuckets,0},
  +                   {num_replicas,0},
  +                   {servers,['n_0@192.168.2.168']},
  +                   {map,[]}]},
  +                 {"default",
  +                  [{autocompaction,[{parallel_db_and_view_compaction,false}]},
  +                   {sasl_password,[]},
  +                   {auth_type,sasl},
  +                   {ram_quota,314572800},
  +                   {num_replicas,1},
  +                   {type,membase},
  +                   {num_vbuckets,16},
  +                   {servers,['n_0@192.168.2.168']},
  +                   {map, some_crap_here}]}]}]}]],
  +    CouchCompactions1 = [{"_default",
  +                          "[{db_fragmentation,\"66\"},{parallel_view_compaction,true},{view_fragmentation,\"80\"}]"},
  +                         {"default","[{parallel_view_compaction,false}]"}],
  +    ?assertEqual({[], []}, decide_autocompaction_config_changes(Cfg1, CouchCompactions1)),
  +
  +    Cfg2 = [[{autocompaction,
  +              [{'_vclock',[{'n_0@192.168.2.168',{1,63481318861}}]},
  +               {parallel_db_and_view_compaction,true},
  +               {database_fragmentation_threshold,66},
  +               {view_fragmentation_threshold,80}]},
  +             {buckets,
  +              [{'_vclock',
  +                [{'n_0@127.0.0.1',{3,63481314227}},
  +                 {'n_0@192.168.2.168',{14,63481323468}}]},
  +               {configs,
  +                [{"mcd",
  +                  [{ram_quota,314572800},
  +                   {auth_type,sasl},
  +                   {sasl_password,[]},
  +                   {type,memcached},
  +                   {num_vbuckets,0},
  +                   {num_replicas,0},
  +                   {servers,['n_0@192.168.2.168']},
  +                   {map,[]}]},
  +                 {"default",
  +                  [{autocompaction,false},
  +                   {sasl_password,[]},
  +                   {auth_type,sasl},
  +                   {ram_quota,314572800},
  +                   {num_replicas,1},
  +                   {type,membase},
  +                   {num_vbuckets,16},
  +                   {servers,['n_0@192.168.2.168']},
  +                   {map, some_crap_here}]}]}]}]],
  +    CouchCompactions2 = [{"_default",
  +                          "[{db_fragmentation,\"66\"},{parallel_view_compaction,true},{view_fragmentation,\"80\"}]"},
  +                         {"default","[{parallel_view_compaction,false}]"}],
  +    ?assertEqual({[], ["default"]}, decide_autocompaction_config_changes(Cfg2, CouchCompactions2)),
  +
  +    Cfg3 = [[{autocompaction,
  +              [{'_vclock',[{'n_0@192.168.2.168',{1,63481318861}}]},
  +               {parallel_db_and_view_compaction,true},
  +               {database_fragmentation_threshold,66},
  +               {view_fragmentation_threshold,80}]},
  +             {buckets,
  +              [{'_vclock',
  +                [{'n_0@127.0.0.1',{3,63481314227}},
  +                 {'n_0@192.168.2.168',{14,63481323468}}]},
  +               {configs,
  +                [{"mcd",
  +                  [{ram_quota,314572800},
  +                   {auth_type,sasl},
  +                   {sasl_password,[]},
  +                   {type,memcached},
  +                   {num_vbuckets,0},
  +                   {num_replicas,0},
  +                   {servers,['n_0@192.168.2.168']},
  +                   {map,[]}]},
  +                 {"default",
  +                  [{autocompaction,[{parallel_db_and_view_compaction,false},
  +                                    {database_fragmentation_threshold, 55}]},
  +                   {sasl_password,[]},
  +                   {auth_type,sasl},
  +                   {ram_quota,314572800},
  +                   {num_replicas,1},
  +                   {type,membase},
  +                   {num_vbuckets,16},
  +                   {servers,['n_0@192.168.2.168']},
  +                   {map, some_crap_here}]}]}]}]],
  +    CouchCompactions3 = [{"_default",
  +                          "[{db_fragmentation,\"66\"},{parallel_view_compaction,true},{view_fragmentation,\"80\"}]"},
  +                         {"default","[{parallel_view_compaction,false}]"}],
  +    ?assertEqual({[{"default","[{db_fragmentation,\"55\"},{parallel_view_compaction,false}]"}], []},
  +                 decide_autocompaction_config_changes(Cfg3, CouchCompactions3)).
  +
  +-endif.
  
positive.code:     State#state{have_notable_change = false,
                  sync_started = true}.
  
  do_config_sync() ->
      Config = ns_config:get(),
      case ns_config:search(Config, {node, node(), couchdb}) of
          {value, CouchDBCfg} ->
              update_couchdb_config(CouchDBCfg);
          _ -> ok
      end.
  
  update_couchdb_config(Config) ->
      %% Updates couch config. Returns true if couchdb needs to be restarted.
      MaybeUpdate =
          fun ({Key, Value}) ->
  
negative.code: %% Auxiliary functions.
  
  is_notable_event({{node, Node, couchdb}, _}) when Node =:= node() -> true;
  is_notable_event({buckets, _}) -> true;
  is_notable_event({autocompaction, _}) -> true;
  is_notable_event(_) -> false.
  
  handle_config_event(KVPair, State) ->
  