mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: force backend commit before acking physical compaction
This commit is contained in:
parent
2f785015a5
commit
81de5648d9
@ -98,6 +98,12 @@ func (s *EtcdServer) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.
|
|||||||
result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{Compaction: r})
|
result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{Compaction: r})
|
||||||
if r.Physical && result.physc != nil {
|
if r.Physical && result.physc != nil {
|
||||||
<-result.physc
|
<-result.physc
|
||||||
|
// The compaction is done deleting keys; the hash is now settled
|
||||||
|
// but the data is not necessarily committed. If there's a crash,
|
||||||
|
// the hash may revert to a hash prior to compaction completing
|
||||||
|
// if the compaction resumes. Force the finished compaction to
|
||||||
|
// commit so it won't resume following a crash.
|
||||||
|
s.be.ForceCommit()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -357,16 +357,21 @@ func (s *store) restore() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, scheduledCompactBytes := tx.UnsafeRange(metaBucketName, scheduledCompactKeyName, nil, 0)
|
_, scheduledCompactBytes := tx.UnsafeRange(metaBucketName, scheduledCompactKeyName, nil, 0)
|
||||||
|
scheduledCompact := int64(0)
|
||||||
if len(scheduledCompactBytes) != 0 {
|
if len(scheduledCompactBytes) != 0 {
|
||||||
scheduledCompact := bytesToRev(scheduledCompactBytes[0]).main
|
scheduledCompact = bytesToRev(scheduledCompactBytes[0]).main
|
||||||
if scheduledCompact > s.compactMainRev {
|
if scheduledCompact <= s.compactMainRev {
|
||||||
log.Printf("storage: resume scheduled compaction at %d", scheduledCompact)
|
scheduledCompact = 0
|
||||||
go s.Compact(scheduledCompact)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Unlock()
|
tx.Unlock()
|
||||||
|
|
||||||
|
if scheduledCompact != 0 {
|
||||||
|
s.Compact(scheduledCompact)
|
||||||
|
log.Printf("storage: resume scheduled compaction at %d", scheduledCompact)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user