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

bug Redis multi-node can acquire lock success #1

Open
tx991020 opened this issue Jul 22, 2022 · 0 comments
Open

bug Redis multi-node can acquire lock success #1

tx991020 opened this issue Jul 22, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@tx991020
Copy link

tx991020 commented Jul 22, 2022

node1

client, err := valkeyrie.NewStore(store.REDIS, []string{"localhost:6379"}, &store.Config{
	
	})
	if err != nil {
		panic(err)
	}

	lock, err := client.NewLock("lock2", &store.LockOptions{
		Value:          []byte("node"),
		TTL:            time.Second * 20,
		DeleteOnUnlock: true,
	})
	if err != nil {
		panic(err)
	}
	i, err := lock.Lock(nil)
	if err != nil {
		panic(err)
	}
	for {
		select {
		case <-i:
			fmt.Println("lock success")
			time.Sleep(time.Second * 2)
		}
	}

node2

client, err := valkeyrie.NewStore(store.REDIS, []string{"localhost:6379"}, &store.Config{
	
	})
	if err != nil {
		panic(err)
	}

	lock, err := client.NewLock("lock2", &store.LockOptions{
		Value:          []byte("node"),
		TTL:            time.Second * 20,
		DeleteOnUnlock: true,
	})
	if err != nil {
		panic(err)
	}
	i, err := lock.Lock(nil)
	if err != nil {
		panic(err)
	}
	for {
		select {
		case <-i:
			fmt.Println("lock success")
			time.Sleep(time.Second * 2)
		}
	}
@ldez ldez added the bug Something isn't working label Aug 3, 2022
@ldez ldez transferred this issue from kvtools/valkeyrie Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants