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

can not get lock after release. #141

Open
xiaoyulei opened this issue Oct 27, 2016 · 2 comments
Open

can not get lock after release. #141

xiaoyulei opened this issue Oct 27, 2016 · 2 comments

Comments

@xiaoyulei
Copy link

I write a simple program to test locker. I found locker2 can not get lock after locker1 Unlock.

func main() {                                                                                                                                                                             
        stopChan1 := make(chan struct{})                                                                                                                                                  
        stopChan2 := make(chan struct{})                                                                                                                                                  

        etcd.Register()                                                                                                                                                                   
        s, _ := libkv.NewStore(store.ETCD, []string{"127.0.0.1:2379"}, nil)                                                                                                               
        locker1, _ := s.NewLock("/test", &store.LockOptions{Value: []byte("testvalue"), TTL: 2 * time.Second})                                                                            
        locker2, _ := s.NewLock("/test", &store.LockOptions{Value: []byte("testvalue2"), TTL: 3 * time.Second})                                                                           

        fmt.Println("start lock locker1")                                                                                                                                                 
        locker1.Lock(stopChan1)                                                                                                                                                           
        fmt.Println("get locker1")                                                                                                                                                        

        go func() {                                                                                                                                                                       
                fmt.Println("start lock locker2")                                                                                                                                         
                locker2.Lock(stopChan2)                                                                                                                                                   
                fmt.Println("get locker2")                                                                                                                                                

                locker2.Unlock()                                                                                                                                                          
                fmt.Println("unlock locker2")                                                                                                                                             
        }()                                                                                                                                                                               

        time.Sleep(3 * time.Second)                                                                                                                                                       
        fmt.Println("start unlock locker1")                                                                                                                                               
        locker1.Unlock()                                                                                                                                                                  
        fmt.Println("unlock locker1")                                                                                                                                                     
        time.Sleep(5 * time.Second)                                                                                                                                                       

}                   
get locker1                                                                                 
start lock locker2                                                                          
start unlock locker1                                                                        
unlock locker1
@abronan
Copy link
Contributor

abronan commented Aug 28, 2017

This is fixed in abronan/libkv (I tested with that example)

@jlhawn
Copy link
Contributor

jlhawn commented Dec 19, 2017

This should be fixed by #186 which includes a test case for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants