yorkie-team/yorkie

Handle housekeeping with sharded cluster

Opened this issue · 4 comments

What would you like to be added:

We recently introduced cluster mode based on the shard key. This shard key is used to assign APIs requested by clients to servers in the cluster based on project or document.

Housekeeping operations should also apply this sharded cluster structure. We can think of two options:

  1. Only the master server executes housekeeping in the cluster
  2. Split housekeeping tasks per project and execute them on servers mapped by project

Why is this needed:

  • Bugs may occur in housekeeping of sharded cluster.
krapie commented

The options that you've suggested look good to me.
I have listed some of the considerations for these options below.

  1. Only the master server executes housekeeping in the cluster.
  1. Split housekeeping tasks per project and execute them on servers mapped by project.

These options seem like opposite options to me, but I think they both can be implemented by using etcd.
I'll keep searching for more information on these options.

krapie commented

I have implemented leader election with K8s lease object, but this will make yorkie k8s dependent.

Therefore, I will change this implementation with MongoDB, where yorkie already have dependency on.

To be specific about the implementation, I will use the way of nodes try to update on the same document(same _id) by checking lease_expire_at field.

Also, to ensure that only one node becomes the leader when a lease has expired, I will use TTL indexes to remove document on expiry, preventing nodes to update the same document simultaneously.

@hackerwins Are we proceeding this issue?

No, it's still on hold. During housekeeping, it seems that Client Deactivation competing across nodes doesn't cause significant issues, so we haven't proceeded with this.