Browse Source

Merge pull request #6309 from xiang90/fix_upgrade

etcdserver: allow zero kv index for cluster upgrade
Xiang Li 9 years ago
parent
commit
b9cd329c61
1 changed files with 6 additions and 1 deletions
  1. 6 1
      etcdserver/server.go

+ 6 - 1
etcdserver/server.go

@@ -408,8 +408,13 @@ func NewServer(cfg *ServerConfig) (srv *EtcdServer, err error) {
 	srv.kv = mvcc.New(srv.be, srv.lessor, &srv.consistIndex)
 	srv.kv = mvcc.New(srv.be, srv.lessor, &srv.consistIndex)
 	if beExist {
 	if beExist {
 		kvindex := srv.kv.ConsistentIndex()
 		kvindex := srv.kv.ConsistentIndex()
+		// TODO: remove kvindex != 0 checking when we do not expect users to upgrade
+		// etcd from pre-3.0 release.
 		if snapshot != nil && kvindex < snapshot.Metadata.Index {
 		if snapshot != nil && kvindex < snapshot.Metadata.Index {
-			return nil, fmt.Errorf("database file (%v index %d) does not match with snapshot (index %d).", bepath, kvindex, snapshot.Metadata.Index)
+			if kvindex != 0 {
+				return nil, fmt.Errorf("database file (%v index %d) does not match with snapshot (index %d).", bepath, kvindex, snapshot.Metadata.Index)
+			}
+			plog.Warningf("consistent index never saved (snapshot index=%d)", snapshot.Metadata.Index)
 		}
 		}
 	}
 	}
 	srv.consistIndex.setConsistentIndex(srv.kv.ConsistentIndex())
 	srv.consistIndex.setConsistentIndex(srv.kv.ConsistentIndex())