can not get lock after release.

Open
#141 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
go

Research direction

Start by running the provided Go reproduction with the etcd-backed store and follow the NewLock, Lock, and Unlock entry points for both lockers. Done means locker2 acquires the /test lock after locker1.Unlock, then can unlock it successfully; add or run a regression test if the repository provides a relevant lock-test location.

Written by the indexing model from the issue text.

Description

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
Dominant language
Go
Stars
847
Forks
204
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docker/libkv

All issues in docker/libkv

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.