Преглед изворни кода

etcd-tester: no error for compact double-send

When compactKV request is halted before final acknowledgement,
it used to just continue on the next endpoint. But there could be
a case than compactKV is requested twice, and the first one is already
replicated and applied by the time the second request was to be
applied (returning compact revision error). This skips the case
by parsing the error message.
Gyu-Ho Lee пре 10 година
родитељ
комит
f9b90e13ac
1 измењених фајлова са 7 додато и 4 уклоњено
  1. 7 4
      tools/functional-tester/etcd-tester/cluster.go

+ 7 - 4
tools/functional-tester/etcd-tester/cluster.go

@@ -327,18 +327,21 @@ func (c *cluster) compactKV(rev int64) error {
 		return nil
 	}
 
-	for _, u := range c.GRPCURLs {
+	for i, u := range c.GRPCURLs {
 		conn, err = grpc.Dial(u, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second))
 		if err != nil {
 			continue
 		}
 		kvc := pb.NewKVClient(conn)
-		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+		ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
 		_, err = kvc.Compact(ctx, &pb.CompactionRequest{Revision: rev, Physical: true})
 		cancel()
 		conn.Close()
-		if err == nil {
-			return nil
+		if err != nil {
+			if strings.Contains(err.Error(), "required revision has been compacted") && i > 0 {
+				plog.Printf("%s is already compacted with %d (%v)", u, rev, err)
+				err = nil // in case compact was requested more than once
+			}
 		}
 	}
 	return err