Graylog2 / graylog-plugin-integrations

A collection of open source Graylog integrations that will be released together.
Other
14 stars 14 forks source link

Distributed Lock/Lease Function #773

Open waab76 opened 3 years ago

waab76 commented 3 years ago

In order to support polling inputs failing over when the primary node fails (and other use cases), we need a distributed lock/lease function supported in Graylog.

Notes

Will need a single interface with a Mongo implementation and possibly a Cloud implementation. Need an atomic function like:

boolean claim(lease_id, client_id, duration) {
  if (lease exists) {
    if (client owns lease OR current time > expire time) {
      upsert lease record with client_id and new expire time
      return true
    } else {
      return false
    }
  } else {
    claim lease for client with expire time
    return true
  }
}

Will probably need to ensure lease/lock collection is indexed to enforce uniqueness. Need to consider how it will behave in a multi-node Mongo cluster.

Polling inputs will need to attempt to claim a lease before they can run. If the claim fails, they no-op.

Input Criteria

Acceptance Criteria

Tasks

bernd commented 3 years ago

@waab76 Thanks for starting this issue! :+1: We talked about locking in the job scheduler context about two years ago so I will add some thoughts from that discussion: