anchor.diff:              BatchMap = Queue1#queue.batch_map,
               Since = Queue1#queue.since,
               Batch0 = maps:get(SpaceId, BatchMap, #batch{since = Since, until = Until}),
  -            ?debug("aaaaa ~p", [{Batch0#batch.until, Until, Since}]),
               UntilToSet = max(Batch0#batch.until, Until),
               Batch = Batch0#batch{changes = [Change | Batch0#batch.changes], until = UntilToSet},
               Queue1#queue{batch_map = maps:put(SpaceId, Batch, BatchMap),
  
positive.code:                     Queue#queue{batch_map = NewBatchMap}
              end;
              (undefined) when QueueKey =:= global ->
                  ?info("[ DBSync ] mmmmm ~p", [QueueKey]),
                  timer:send_after(?FLUSH_QUEUE_INTERVAL, whereis(dbsync_worker), {timer, {flush_queue, QueueKey}}),
                  undefined;
              (undefined) ->
                  ?warning("Unknown operation on empty queue ~p", [QueueKey]),
                  undefined
          end),
      ?info("[ DBSync ] Flush queue4 ~p", [{QueueKey, Ans}]),
      Ans
      catch
          E1:E2 ->
              ?info("[ DBSync ] Flush queue3 ~p", [{QueueKey, E1,E2}]),
              throw(E2)
      end ;
  
  %% Handle external dbsync requests
  handle({dbsync_request, SessId, DBSyncRequest}) ->
  
negative.code: 
  %% Append change to given queue
  handle({QueueKey, #change{seq = Seq, doc = #document{key = Key, rev = Rev} = Doc} = Change}) ->
      ?debug("[ DBSync ] Received change on queue ~p with seq ~p: ~p", [QueueKey, Seq, Doc]),
      dbsync_utils:temp_put(last_change, erlang:monotonic_time(milli_seconds), 0),
      Rereplication = QueueKey =:= global andalso dbsync_utils:temp_get({replicated, Key, Rev}) =:= true,
      case {has_sync_context(Doc), Rereplication} of
  