anchor.diff:                        end, not_present),
       ok.
   
  -maybe_update_ephemeral_full_policy(Sock, Bucket, NewFullPolicy, CurrFullPolicy) ->
  -    case NewFullPolicy =/= CurrFullPolicy of
  +maybe_set_num_threads(Bucket, ReloadBuckets, NewNumThreads, ActualNumThreadsBin) ->
  +    NewNumThreadsBin = list_to_binary(integer_to_list(NewNumThreads)),
  +    case ReloadBuckets andalso NewNumThreadsBin =/= ActualNumThreadsBin of
           true ->
  -            ok = mc_client_binary:set_flush_param(Sock,
  +            ale:info(?USER_LOGGER,
  +                     "Bucket priority changed from ~s to ~s for bucket ~p",
  +                     [ActualNumThreadsBin, NewNumThreadsBin, Bucket]),
  +            {ok, needs_restart};
  +        false ->
  +            ok
  +    end.
  +
  +maybe_set_item_eviction_policy(_, _, undefined, _) ->
  +    ok;
  +maybe_set_item_eviction_policy(Bucket, ReloadBuckets, NewPolicy, ActualPolicyBin) ->
  +    NewPolicyBin = atom_to_binary(NewPolicy, latin1),
  +    case ReloadBuckets andalso NewPolicyBin =/= ActualPolicyBin of
  +        true ->
  +            ale:info(?USER_LOGGER,
  +                     "Eviction policy changed from '~s' to '~s' for bucket ~p",
  +                     [ActualPolicyBin, NewPolicyBin, Bucket]),
  +            {ok, needs_restart};
  +        false ->
  +            ok
  +    end.
  +
  +maybe_set_ephemeral_full_policy(_, _, undefined, _) ->
  +    ok;
  +maybe_set_ephemeral_full_policy(Sock, Bucket, NewPolicy, ActualPolicyBin) ->
  +    NewPolicyBin = atom_to_binary(NewPolicy, latin1),
  +    case NewPolicyBin =/= ActualPolicyBin of
  +        true ->
  +            ok = mc_client_binary:set_engine_param(Sock,
                                                      <<"ephemeral_full_policy">>,
  -                                                   NewFullPolicy),
  +                                                   NewPolicyBin,
  +                                                   flush),
               ?log_info("Ephemeral full policy changed from '~s' to '~s' for bucket ~p",
  -                      [CurrFullPolicy, NewFullPolicy, Bucket]),
  +                      [ActualPolicyBin, NewPolicyBin, Bucket]),
               ok;
           false ->
               ok
       end.
   
  +maybe_set_ephemeral_metadata_purge_age(_, _, undefined, _) ->
  +    ok;
   maybe_set_ephemeral_metadata_purge_age(Sock, Bucket, NewPurgeAge, CurrPurgeAge) ->
  -    case NewPurgeAge =/= CurrPurgeAge of
  +    NewPurgeAgeBin = list_to_binary(integer_to_list(NewPurgeAge)),
  +    case NewPurgeAgeBin =/= CurrPurgeAge of
           true ->
               ok = mc_client_binary:set_flush_param(Sock,
  -                                                   <<"ephemeral_metadata_purge_age">>,
  -                                                   NewPurgeAge),
  +                                                  <<"ephemeral_metadata_purge_age">>,
  +                                                  NewPurgeAgeBin),
               ?log_info("Ephemeral metadata purge age changed from '~s' to '~s' for bucket ~p",
  -                      [CurrPurgeAge, NewPurgeAge, Bucket]),
  +                      [CurrPurgeAge, NewPurgeAgeBin, Bucket]),
               ok;
           false ->
               ok
  +    end.
  +
  +maybe_set_drift_thresholds(_Sock, _Bucket, undefined, _, _) ->
  +    ok;
  +maybe_set_drift_thresholds(Sock, Bucket, {DAT, DBT}, ActualDAT, ActualDBT) ->
  +    DATBin = list_to_binary(integer_to_list(misc:msecs_to_usecs(DAT))),
  +    DBTBin = list_to_binary(integer_to_list(misc:msecs_to_usecs(DBT))),
  +    DATChanged = (DATBin =/= ActualDAT),
  +    DBTChanged = (DBTBin =/= ActualDBT),
  +
  +    case DATChanged of
  +        true ->
  +            ok = mc_client_binary:set_engine_param(Sock,
  +                                                   <<"hlc_drift_ahead_threshold_us">>,
  +                                                   DATBin,
  +                                                   vbucket),
  +            ?log_info("Drift ahead threshold changed from '~s' to '~s' for bucket ~p",
  +                      [ActualDAT, DATBin, Bucket]);
  +        false ->
  +            ok
  +    end,
  +
  +    case DBTChanged of
  +        true ->
  +            ok = mc_client_binary:set_engine_param(Sock,
  +                                                   <<"hlc_drift_behind_threshold_us">>,
  +                                                   DBTBin,
  +                                                   vbucket),
  +            ?log_info("Drift behind threshold changed from '~s' to '~s' for bucket ~p",
  +                      [ActualDBT, DBTBin, Bucket]);
  +        false ->
  +            ok
  +    end.
  +
  +maybe_set_max_size(Sock, Bucket, NewMaxSize, ActualMaxSizeBin) ->
  +    NewMaxSizeBin = list_to_binary(integer_to_list(NewMaxSize)),
  +    case ActualMaxSizeBin of
  +        NewMaxSizeBin ->
  +            ok;
  +        X1 when is_binary(X1) ->
  +            ?log_info("Changing max_size of ~p from ~s to ~s", [Bucket, X1,
  +                                                                NewMaxSizeBin]),
  +            ok = mc_client_binary:set_flush_param(Sock, <<"max_size">>, NewMaxSizeBin)
  +    end.
  +
  +maybe_set_db_dir(Bucket, NewDBDir, ActualDBDirBin) ->
  +    NewDBDirBin = list_to_binary(NewDBDir),
  +    case ActualDBDirBin of
  +        NewDBDirBin ->
  +            ok;
  +        X2 when is_binary(X2) ->
  +            ?log_info("Changing dbname of ~p from ~s to ~s", [Bucket, X2,
  +                                                              NewDBDirBin]),
  +            %% Just exit; this will delete and recreate the bucket
  +            {ok, needs_restart}
       end.
   
   server(Bucket) ->
  
positive.code:                   QStats
            end, #qstats{}),
  
      CanReloadBuckets = ns_config:read_key_fast(dont_reload_bucket_on_cfg_change, false) =:= false,
  
      NumThreadsChanged = CanReloadBuckets andalso (NumThreadsBin =/= ActualNumThreads),
  
      ItemEvictionPolicyChanged = CanReloadBuckets
          andalso ItemEvictionPolicy =/= undefined
          andalso (ItemEvictionPolicyBin =/= ActualItemEvictionPolicy),
  
      case NumThreadsChanged of
          true ->
              ale:info(?USER_LOGGER,
                       "Bucket priority changed from ~s to ~s for bucket ~p",
                       [ActualNumThreads, NumThreadsBin, Bucket]);
          false ->
              ok
      end,
  
      case ItemEvictionPolicyChanged of
          true ->
              ale:info(?USER_LOGGER,
                       "Eviction policy changed from '~s' to '~s' for bucket ~p",
                       [ActualItemEvictionPolicy, ItemEvictionPolicyBin, Bucket]);
          false ->
              ok
      end,
  
      case EphemeralFullPolicy =/= undefined of
          true ->
              maybe_update_ephemeral_full_policy(Sock, Bucket, EphemeralFullPolicyBin,
                                                 ActualEphemeralFullPolicy);
          false ->
              ok
      end,
  
      case EphemeralPurgeAge =/= undefined of
          true ->
              EphemeralPurgeAgeBin = list_to_binary(integer_to_list(EphemeralPurgeAge)),
              maybe_set_ephemeral_metadata_purge_age(Sock, Bucket, EphemeralPurgeAgeBin,
                                                     ActualPurgeAge);
          false ->
              ok
      end,
  
      maybe_set_drift_thresholds(Sock, Bucket, DriftThresholds, ActualDAT, ActualDBT),
  
      case NumThreadsChanged orelse ItemEvictionPolicyChanged of
          true ->
              ale:info(?USER_LOGGER,
                       "Restarting bucket ~p due to configuration change",
                       [Bucket]),
              exit({shutdown, reconfig});
          false ->
              case ActualMaxSizeBin of
                  MaxSizeBin ->
                      ok;
                  X1 when is_binary(X1) ->
                      ?log_info("Changing max_size of ~p from ~s to ~s", [Bucket, X1,
                                                                          MaxSizeBin]),
                      ok = mc_client_binary:set_flush_param(Sock, <<"max_size">>, MaxSizeBin)
              end,
              case ActualDBDirBin of
                  DBDirBin ->
                      ok;
                  X2 when is_binary(X2) ->
                      ?log_info("Changing dbname of ~p from ~s to ~s", [Bucket, X2,
                                                                        DBDirBin]),
                      %% Just exit; this will delete and recreate the bucket
                      exit({shutdown, reconfig})
              end
      end;
  ensure_bucket_config(Sock, _Bucket, memcached, _MaxSize) ->
      %% TODO: change max size of memcached bucket also
  
negative.code:             {E, R}
      end.
  
  -record(qstats, {max_size = missng_max_size,
                   dbname = missing_path,
                   max_num_workers = missing_num_threads,
  