Uploaded image for project: 'Apache RocketMQ'
  1. Apache RocketMQ
  2. ROCKETMQ-98

Risk of unable to release putMessage Lock forever

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.1.0-incubating
    • 4.1.0-incubating
    • None
    • None

    Description

      In current implemenation, there are two kind of locks dev can choose. If I choose reentrantLock, and lock it then put message, in this time I change the config through admin interface to use spin lock. When trying to unlock, rocketmq will try to unlock the spin lock though actually the reentrantlock is locked, this will cause the reentrantlock not able to release forever and trying to release the wrong spin lock but actully it is not locked!

      /**

      • Spin util acquired the lock.
        */
        private void lockForPutMessage() {
        if (this.defaultMessageStore.getMessageStoreConfig().isUseReentrantLockWhenPutMessage()) { putMessageNormalLock.lock(); }

        else

        Unknown macro: { boolean flag; do { flag = this.putMessageSpinLock.compareAndSet(true, false); } while (!flag); }

        }

      private void releasePutMessageLock() {
      if (this.defaultMessageStore.getMessageStoreConfig().isUseReentrantLockWhenPutMessage())

      { putMessageNormalLock.unlock(); }

      else

      { this.putMessageSpinLock.compareAndSet(false, true); }

      }

      Attachments

        Issue Links

          Activity

            People

              Jaskey Jaskey Lam
              Jaskey Jaskey Lam
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Slack

                  Issue deployment