Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restarted etcd returns different hash #7359

Closed
gyuho opened this issue Feb 21, 2017 · 2 comments · Fixed by #7364
Closed

restarted etcd returns different hash #7359

gyuho opened this issue Feb 21, 2017 · 2 comments · Fixed by #7364
Labels
Milestone

Comments

@gyuho
Copy link
Contributor

gyuho commented Feb 21, 2017

No write is done. Just stop and restart one single node.

With current master branch at 0c0fbbd

# start one single node

# get hash
connecting to localhost:2379
"localhost:2379" got status &{Header:cluster_id:8456392909007433582 member_id:18244812706509296096 revision:1 raft_term:2  Version:3.2.0+git DbSize:24576 Leader:18244812706509296096 RaftIndex:4 RaftTerm:2}
"localhost:2379" got hash 215001531

# stop and restart the node

# get hash
connecting to localhost:2379
"localhost:2379" got status &{Header:cluster_id:8456392909007433582 member_id:18244812706509296096 revision:1 raft_term:3  Version:3.2.0+git DbSize:24576 Leader:18244812706509296096 RaftIndex:6 RaftTerm:3}
"localhost:2379" got hash 2060568856
import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/coreos/etcd/clientv3"
	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
	"google.golang.org/grpc"
)

var endpoints = []string{"localhost:2379"}

func main() {
	printHashes(endpoints)
}

func printHashes(eps []string) {
	for _, ep := range eps {
		fmt.Println("connecting to", ep)
		cli, err := clientv3.New(clientv3.Config{
			Endpoints:   []string{ep},
			DialTimeout: 3 * time.Second,
		})
		if err != nil {
			log.Fatal(err)
		}
		defer cli.Close()

		ctx, cancel := context.WithTimeout(context.Background(), time.Second)
		resp, err := cli.Status(ctx, ep)
		cancel()
		if err != nil {
			log.Fatal(err)
		}
		fmt.Printf("%q got status %+v\n", ep, resp)

		conn, err := grpc.Dial(ep, grpc.WithTimeout(time.Second), grpc.WithInsecure())
		if err != nil {
			log.Fatal(err)
		}
		mc := pb.NewMaintenanceClient(conn)
		ctx, cancel = context.WithTimeout(context.Background(), time.Second)
		var hresp *pb.HashResponse
		hresp, err = mc.Hash(ctx, &pb.HashRequest{}, grpc.FailFast(false))
		cancel()
		if err != nil {
			log.Fatal(err)
		}
		fmt.Printf("%q got hash %d\n", ep, hresp.Hash)

		time.Sleep(time.Second)
	}
}
@xiang90 xiang90 added this to the v3.2.0 milestone Feb 21, 2017
@gyuho
Copy link
Contributor Author

gyuho commented Feb 21, 2017

This doesn't happen in v3.1.0

connecting to localhost:2379
"localhost:2379" got status &{Header:cluster_id:8456392909007433582 member_id:18244812706509296096 revision:1 raft_term:2  Version:3.1.0 DbSize:24576 Leader:18244812706509296096 RaftIndex:4 RaftTerm:2}
"localhost:2379" got hash 3606812028

connecting to localhost:2379
"localhost:2379" got status &{Header:cluster_id:8456392909007433582 member_id:18244812706509296096 revision:1 raft_term:3  Version:3.1.0 DbSize:24576 Leader:18244812706509296096 RaftIndex:6 RaftTerm:3}
"localhost:2379" got hash 3606812028

But happens in v3.1.1

connecting to localhost:2379
"localhost:2379" got status &{Header:cluster_id:8456392909007433582 member_id:18244812706509296096 revision:1 raft_term:2  Version:3.1.1 DbSize:24576 Leader:18244812706509296096 RaftIndex:4 RaftTerm:2}
"localhost:2379" got hash 3606812028

connecting to localhost:2379
"localhost:2379" got status &{Header:cluster_id:8456392909007433582 member_id:18244812706509296096 revision:1 raft_term:3  Version:3.1.1 DbSize:24576 Leader:18244812706509296096 RaftIndex:6 RaftTerm:3}
"localhost:2379" got hash 2700801503

Will investigate more.

@heyitsanthony
Copy link
Contributor

@gyuho may be related to the auth enabled fix

gyuho added a commit to gyuho/etcd that referenced this issue Feb 21, 2017
When there's no changes yet (right after auth
store initialization), we should commit old revision.

Fix etcd-io#7359.
gyuho added a commit to gyuho/etcd that referenced this issue Feb 22, 2017
When there's no changes yet (right after auth
store initialization), we should commit old revision.

Fix etcd-io#7359.
gyuho added a commit to gyuho/etcd that referenced this issue Feb 22, 2017
When there's no changes yet (right after auth
store initialization), we should commit old revision.

Fix etcd-io#7359.
gyuho added a commit that referenced this issue Feb 22, 2017
When there's no changes yet (right after auth
store initialization), we should commit old revision.

Fix #7359.
gyuho added a commit that referenced this issue Feb 22, 2017
When there's no changes yet (right after auth
store initialization), we should commit old revision.

Fix #7359.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants