4 Replies Latest reply on Mar 12, 2007 2:06 PM by manik

    Distributed Lock Mechanism

    epbernard

      Hi guys,
      For Hibernate Search, I'm in need for a DLM (Distributed Lock Mechanism). Basically a way to acquire a lock, do some stuff and release a lock clusterwise.

      This is something that can be available and built on top of JGroups.

      I've talked to a RH instructor and we discussed the DLM available in GFS (Global file System).
      To summarize:
      - there is a quorum (each node having a weight)
      - a subset of the cluster is considered free to work if it has quorum/2+1
      - when a node ask for a lock, it informs everybody, and everybody has to agree on the lock acquisition
      - if a lock is acquired the demanding node is responsible for managing the lock
      - if a node is playing the bad guy or has been cut from the majority, it reboots itself or is made rebooted hoping for a recovery

      This implementation is not really fully self configurable (entering and leaving the quorum part might have to be manual)

      Do you think we can build something similar as a common project for JBoss, I need it but most likely, some other projects need that too.
      I'm pretty open to the feature support as well.
      There may be something available already?

      Thoughts?

        • 1. Re: Distributed Lock Mechanism
          belaban

          There is a DLM that's part of JGroups but it is somewhat unsupported (I didn't write it and the guy who did is too busy to support it): http://www.koders.com/java/fidC73888EED1C2ECCDD56AF33274914F9AB36641F7.aspx?s=DistributedLockManager

          The existing DLM is also a bit costly, as it does a 2-phase lock acquisition phase. Also, IIRC it requires total consensus, not majority-based consensus as you described above.
          You also have to solve the issue where a member which is currently holding the lock crashes. In this case, you have to release all the locks held by a crashed member.

          If you submit a concise spec then something like what you described could be implemented in a few days...

          • 2. Re: Distributed Lock Mechanism
            manik

            Perhaps something similar to the DLM in JGroups could be implemented as a part of a common clustering library, as I think it takes away from JGroups' core focus to have it reside in JGroups. (IMO)

            Re: the problem of the lock owner crashing, surely JGroups FD can kick in, and when a new view is issued, locks held by missing members can be automatically released?

            Further, timeouts can be applied to ensure locks cannot be held forever, although this may undermine the purpose of the lock in the first place. Replicated deadlock, anyone? :-)

            • 3. Re: Distributed Lock Mechanism
              belaban

              The issue of releasing locks from crashed members has already been solved and is part of the current DLM, I just mentioned it as one of the issues for a potential re-implementation.
              Yes, leasing of locks could help preventing distributed deadlocks, this could be part of a new implementation.

              • 4. Re: Distributed Lock Mechanism
                manik

                Pls see this thread which is related