You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/04/10 13:57:13 UTC

[GitHub] [rocketmq] MatrixHB opened a new issue, #4142: RemotingCommand is not thread-safe

MatrixHB opened a new issue, #4142:
URL: https://github.com/apache/rocketmq/issues/4142

   There are 3 fields in `RemotingCommand` using HashMap. 
   When the HashMap state is modified by one thread, another thread could call get.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] github-actions[bot] commented on issue #4142: RemotingCommand is not thread-safe

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1588274060

   This issue was closed because it has been inactive for 3 days since being marked as stale.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on issue #4142: RemotingCommand is not thread-safe

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1150618821

   @ni-ze 
   > When modifies the map structurally, such as HashMap.put, synchronized already used.
   
   This is simply wrong. Sync the write op alone is not enough. The read thread may potentially be trapped in an infinite loop while iterating when `rehash` happens. 
   
   This bug is less likely to trigger because this map is not frequently changed, especially in structure.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on issue #4142: RemotingCommand is not thread-safe

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1150612364

   @dugenkui03 You are right, definitely, this is a data race bug. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] dugenkui03 commented on issue #4142: RemotingCommand is not thread-safe

Posted by GitBox <gi...@apache.org>.
dugenkui03 commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1099942336

   jdk文档的意思是当有至少有一个线程写数据时、任何访问HashMap的线程都要加锁、包括读写。
   
   如下 thread_write 正在写入数据并导致 HashMap的**结构正在发生变化**,thread_read 此时访问数据是不安全的。
   <img width="685" alt="image" src="https://user-images.githubusercontent.com/18216266/163542401-4decee7d-dc0a-4e34-b4bb-7727e2e93f5f.png">
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] MatrixHB commented on issue #4142: RemotingCommand is not thread-safe

Posted by GitBox <gi...@apache.org>.
MatrixHB commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1094280499

   [#4138](https://github.com/apache/rocketmq/pull/4138)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] dugenkui03 commented on issue #4142: RemotingCommand is not thread-safe

Posted by GitBox <gi...@apache.org>.
dugenkui03 commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1097828873

   @ni-ze The read-thread maybe get unexpected value, instread of the latest value.  Details in [jdk document](https://github.com/openjdk/jdk/blob/280aa428800043f314b92ae88076d596cb4c2fe0/src/java.base/share/classes/java/util/HashMap.java#L89).
   
   >Note that this implementation is not synchronized. If multiple threads access a hash map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] github-actions[bot] closed issue #4142: RemotingCommand is not thread-safe

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #4142: RemotingCommand is not thread-safe
URL: https://github.com/apache/rocketmq/issues/4142


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ni-ze commented on issue #4142: RemotingCommand is not thread-safe

Posted by GitBox <gi...@apache.org>.
ni-ze commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1094827468

   IMO,   there is no problem,  use synchronized just protect HaspMap.put. In your case, one thread get data which update by another is correct, it just get the latest value.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ni-ze commented on issue #4142: RemotingCommand is not thread-safe

Posted by GitBox <gi...@apache.org>.
ni-ze commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1099798874

   When modifies the map structurally, such as HashMap.put, synchronized already used.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] github-actions[bot] commented on issue #4142: RemotingCommand is not thread-safe

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #4142:
URL: https://github.com/apache/rocketmq/issues/4142#issuecomment-1585297029

   This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org