mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #4911 from heyitsanthony/physical-already
etcdserver, storage: wait for physical compaction if already compacted
This commit is contained in:
commit
6cf198d1b1
@ -94,12 +94,12 @@ func (s *EtcdServer) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse
|
||||
|
||||
func (s *EtcdServer) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
|
||||
result, err := s.processInternalRaftRequest(ctx, pb.InternalRaftRequest{Compaction: r})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if r.Physical && result.physc != nil {
|
||||
<-result.physc
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := result.resp.(*pb.CompactionResponse)
|
||||
if resp == nil {
|
||||
resp = &pb.CompactionResponse{}
|
||||
|
@ -235,7 +235,9 @@ func (s *store) Compact(rev int64) (<-chan struct{}, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if rev <= s.compactMainRev {
|
||||
return nil, ErrCompacted
|
||||
ch := make(chan struct{})
|
||||
s.fifoSched.Schedule(func(context.Context) { close(ch) })
|
||||
return ch, ErrCompacted
|
||||
}
|
||||
if rev > s.currentRev.main {
|
||||
return nil, ErrFutureRev
|
||||
|
Loading…
x
Reference in New Issue
Block a user