anchor.diff:      {ok, #doc{body = {Props}}} ->
           Seq = couch_db:get_update_seq(ShardDb),
           Shards = mem3_util:build_ordered_shards(DbName, Props),
  -        gen_server:cast(?MODULE, {cache_insert, DbName, Shards, Seq}),
  +        IdleTimeout = config:get_integer("mem3", "writer_idle_timeout", 30000),
  +        case maybe_spawn_shard_writer(DbName, Shards, IdleTimeout) of
  +            Writer when is_pid(Writer) ->
  +                case ets:insert_new(?OPENERS, {DbName, Writer}) of
  +                    true ->
  +                        Msg = {cache_insert, DbName, Writer, Seq},
  +                        gen_server:cast(?MODULE, Msg);
  +                    false ->
  +                        Writer ! cancel
  +                end;
  +            ignore ->
  +                ok
  +        end,
           Shards;
       {not_found, _} ->
           erlang:error(database_does_not_exist, ?b2l(DbName))
  
positive.code:     true = ets:delete_all_objects(?ATIMES),
      St#st{cur_size=0}.
  
  filter_shards_by_name(Name, Shards) ->
      filter_shards_by_name(Name, [], Shards).
  
  
negative.code:         end
      end.
  
  cache_insert(#st{cur_size=Cur}=St, DbName, Writer, Timeout) ->
      NewATime = now(),
      true = ets:delete(?SHARDS, DbName),
      flush_write(DbName, Writer, Timeout),
      case ets:lookup(?DBS, DbName) of
          [{DbName, ATime}] ->
              true = ets:delete(?ATIMES, ATime),
  