datamanager: start initEtcd from last datastatus
This commit is contained in:
parent
445ef24daa
commit
cb2a871be6
@ -1002,6 +1002,17 @@ func (d *DataManager) InitEtcd(ctx context.Context) error {
|
|||||||
|
|
||||||
// walsdata not found in etcd
|
// walsdata not found in etcd
|
||||||
|
|
||||||
|
curDataStatus, err := d.GetLastDataStatus()
|
||||||
|
if err != nil && err != ostypes.ErrNotExist {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// set the first wal to import in etcd if there's a snapshot. In this way we'll
|
||||||
|
// ignore older wals (or wals left after an import)
|
||||||
|
var firstWal string
|
||||||
|
if err == nil {
|
||||||
|
firstWal = curDataStatus.WalSequence
|
||||||
|
}
|
||||||
|
|
||||||
// if there're some wals in the objectstorage this means etcd has been reset.
|
// if there're some wals in the objectstorage this means etcd has been reset.
|
||||||
// So take all the wals in committed or checkpointed state starting from the
|
// So take all the wals in committed or checkpointed state starting from the
|
||||||
// first not checkpointed wal and put them in etcd
|
// first not checkpointed wal and put them in etcd
|
||||||
@ -1015,6 +1026,10 @@ func (d *DataManager) InitEtcd(ctx context.Context) error {
|
|||||||
return wal.Err
|
return wal.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if wal.WalSequence < firstWal {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
lastCommittedStorageWalElem.Value = wal
|
lastCommittedStorageWalElem.Value = wal
|
||||||
lastCommittedStorageWalElem = lastCommittedStorageWalElem.Next()
|
lastCommittedStorageWalElem = lastCommittedStorageWalElem.Next()
|
||||||
lastCommittedStorageWalSequence = wal.WalSequence
|
lastCommittedStorageWalSequence = wal.WalSequence
|
||||||
|
Loading…
Reference in New Issue
Block a user