[ 
https://issues.apache.org/jira/browse/ROCKETMQ-98?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15867133#comment-15867133
 ] 

ASF GitHub Bot commented on ROCKETMQ-98:
----------------------------------------

GitHub user Jaskey opened a pull request:

    https://github.com/apache/incubator-rocketmq/pull/61

    Fix risk of unable to release putMessage Lock forever.

    JIRA: https://issues.apache.org/jira/browse/ROCKETMQ-98

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Jaskey/incubator-rocketmq ROCKETMQ-98

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-rocketmq/pull/61.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #61
    
----
commit 7bcd7c3a0d7253695c98fc8e433375cfc9381a67
Author: Jaskey <[email protected]>
Date:   2017-02-15T03:05:10Z

    Fix risk of unable to release putMessage Lock forever. Unlock the exactly 
lock which is locked

----


> Risk of unable to release putMessage Lock forever
> -------------------------------------------------
>
>                 Key: ROCKETMQ-98
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-98
>             Project: Apache RocketMQ
>          Issue Type: Bug
>            Reporter: Jaskey Lam
>            Assignee: vongosling
>
> 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 {
>             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);
>         }
>     }



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to