yorkie-team/yorkie

Add trylock method to memory locker

Closed this issue ยท 8 comments

What would you like to be added:
trylock method of etcd was added in version 3, and it is required in packs.go.

Why is this needed:

So,

  1. update etcd to v3
  2. add trylock method to etcd/locker.go
  3. use trylock in packs.go.

Trylock has been added to etcd version 3.5, but only version 3.3 has been distributed to pkg.go.dev, so hold it for a while.

We can use etcd 3.5 version. #274
Next, it seems that we need to complete the try lock implementation for the memory.

Oh okay I'll start implementing

@wonjerry The etcd version is implemented in #274. Please review the PR.
It would be good to continue working with the memory version.

// TryLock locks the mutex if not already locked by another session.
func (il *internalLocker) TryLock(ctx context.Context) error {
// TODO(hackerwins): We need to replace Lock with TryLock.
il.locks.Lock(il.key)
return nil
}

After researching a bit, I found that the go's built-in library, sync, added the trylock function in version 1.18, and I am going to try to use this function in the memory version by increasing the go version.

Can I try to increase version of go in yorkie to 1.18?

Oh, the stable version is still 1.17.3. I'll try it when the stable 18 version comes out..

@wonjerry Thanks for your research. It looks like we can get this done soon without stress. ๐Ÿ‘