From 9e3dfc2191b973ea34184de01cc8778e5b55b00d Mon Sep 17 00:00:00 2001 From: siddontang Date: Thu, 12 Jun 2014 21:29:41 +0800 Subject: [PATCH] replication bugfix --- server/replication.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/server/replication.go b/server/replication.go index 2ee0af4..383a244 100644 --- a/server/replication.go +++ b/server/replication.go @@ -87,11 +87,21 @@ func (m *master) loadInfo() error { return err } + println(m.addr, m.logFileIndex, m.logPos) + return nil } func (m *master) saveInfo() error { - data, err := json.Marshal(m) + data, err := json.Marshal(struct { + Addr string `json:"addr"` + LogFileIndex int64 `json:"log_file_index"` + LogPos int64 `json:"log_pos"` + }{ + m.addr, + m.logFileIndex, + m.logPos, + }) if err != nil { return err } @@ -263,7 +273,7 @@ func (m *master) fullSync() error { m.logFileIndex = head.LogFileIndex m.logPos = head.LogPos - return nil + return m.saveInfo() } func (m *master) sync() error { @@ -307,7 +317,7 @@ func (m *master) sync() error { return err } - return nil + return m.saveInfo() }