summary refs log tree commit diff
path: root/synapse/replication
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2016-04-27 15:38:43 +0100
committerMark Haines <mark.haines@matrix.org>2016-04-27 15:38:43 +0100
commit8a656664544fbc23db618aa855cc61ac54d9afeb (patch)
treef8b0b43feaac16f317c8826d98f7a5b1ebe34f24 /synapse/replication
parentActually start the pusher daemon (diff)
downloadsynapse-8a656664544fbc23db618aa855cc61ac54d9afeb.tar.xz
Fix backfill replication to advance the stream correctly
Diffstat (limited to 'synapse/replication')
-rw-r--r--synapse/replication/resource.py2
-rw-r--r--synapse/replication/slave/storage/events.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/synapse/replication/resource.py b/synapse/replication/resource.py
index e5c9a53929..149fc4c650 100644
--- a/synapse/replication/resource.py
+++ b/synapse/replication/resource.py
@@ -382,7 +382,7 @@ class _Writer(object):
             position = rows[-1][0]
 
         self.streams[name] = {
-            "position": str(position),
+            "position": position if type(position) is int else str(position),
             "field_names": fields,
             "rows": rows,
         }
diff --git a/synapse/replication/slave/storage/events.py b/synapse/replication/slave/storage/events.py
index 5f37ba6995..86f00b6ff5 100644
--- a/synapse/replication/slave/storage/events.py
+++ b/synapse/replication/slave/storage/events.py
@@ -118,7 +118,7 @@ class SlavedEventStore(BaseSlavedStore):
     def stream_positions(self):
         result = super(SlavedEventStore, self).stream_positions()
         result["events"] = self._stream_id_gen.get_current_token()
-        result["backfill"] = self._backfill_id_gen.get_current_token()
+        result["backfill"] = -self._backfill_id_gen.get_current_token()
         return result
 
     def process_replication(self, result):
@@ -136,7 +136,7 @@ class SlavedEventStore(BaseSlavedStore):
 
         stream = result.get("backfill")
         if stream:
-            self._backfill_id_gen.advance(stream["position"])
+            self._backfill_id_gen.advance(-stream["position"])
             for row in stream["rows"]:
                 self._process_replication_row(
                     row, backfilled=True, state_resets=state_resets