Merge pull request #4911 from heyitsanthony/physical-already

etcdserver, storage: wait for physical compaction if already compacted
This commit is contained in:
Gyu-Ho Lee 2016-03-30 14:27:21 -07:00
commit 6cf198d1b1
2 changed files with 6 additions and 4 deletions

View File

@ -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{}

View File

@ -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