You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2025/02/05 14:59:00 UTC
[jira] [Work logged] (AMQ-9658) TcpTransport volatile receiveCounter is not incremented atomically
[ https://issues.apache.org/jira/browse/AMQ-9658?focusedWorklogId=955596&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-955596 ]
ASF GitHub Bot logged work on AMQ-9658:
---------------------------------------
Author: ASF GitHub Bot
Created on: 05/Feb/25 14:58
Start Date: 05/Feb/25 14:58
Worklog Time Spent: 10m
Work Description: cshannon commented on PR #1389:
URL: https://github.com/apache/activemq/pull/1389#issuecomment-2637102058
I am going to merge this as tests all passed, one interesting thing to note is that the counter never resets so it could easily overflow if a connection sends more than 2 gigs. It's used by the inactivity monitor (which only cares about changes and not value) so it's probably ok but we should look at moving to a long if we want to track accurate metrics at some point.
Issue Time Tracking
-------------------
Worklog Id: (was: 955596)
Remaining Estimate: 0h
Time Spent: 10m
> TcpTransport volatile receiveCounter is not incremented atomically
> ------------------------------------------------------------------
>
> Key: AMQ-9658
> URL: https://issues.apache.org/jira/browse/AMQ-9658
> Project: ActiveMQ Classic
> Issue Type: Bug
> Affects Versions: 5.18.6, 6.1.5
> Reporter: Christopher L. Shannon
> Assignee: Christopher L. Shannon
> Priority: Minor
> Fix For: 6.2.0, 5.19.0, 6.1.6
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> incrementing volatile integers is not an atomic operation because the previous value must first be read, then incremented, and reset so it is a multi step process. I noticed in the TCP transport code that the receive counter was a volatile integer and not being incremented properly. This counter is should only be incremented in the same thread anyways (it can be read by other threads like inactivity monitor) so it may not technically be an issue in practice but it still should be handled properly.
> The fix is to switch to an AtomicInteger. I also noticed a minor improvement to make to to the NIOSSLtransport init code that is only used for the auto+nio+ssl transport that I will fix as well. (ensure the full initialization buffer will always be entirely read and processed when using the auto+nio+ssl transport. )
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@activemq.apache.org
For additional commands, e-mail: issues-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact