Peter Nowak created CAMEL-20103:
-----------------------------------
Summary: DefaultProducerCache returns wrong ProducerTemplate under
high concurrency load
Key: CAMEL-20103
URL: https://issues.apache.org/jira/browse/CAMEL-20103
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 4.1.0, 4.0.2, 4.0.1, 4.0.0, 4.2.0
Reporter: Peter Nowak
Attachments: patch.diff
as already posted on the [dev mailing
list|https://lists.apache.org/thread/2o0fhstmdjgc0nss0t30d9g3337qnm8j] the
DefaultProducerCache can return a wrong ProducerTemplate under high concurrency
load which leads to misrouted exchanges and therefor errors in the application
and workflow.
The improvement in the DefaultProducerCache from [issue
19058|https://issues.apache.org/jira/browse/CAMEL-19058] introduced a severe
concurrency issue with [that
change|https://github.com/apache/camel/commit/921ce519331ac5c8b0a1dfd099f9acbaba4feeab].
While writing to the "lastUsed" fields in "acquireProducers" is synchronised,
so that they are updated together, the read at the beginning of the method is
not synchronised at all with the writes and therefor can be read at every time,
even between the synced update to the fields which can lead to wrong producer
templates being returned under high concurrency load. This then leads to
exchanges being delivered to wrong endpoints causing severe malfunctions and
errors.
i have created a patch (and also a branch in my forked camel repo) including
the fix and a unit test reproduces the problem with returning the wrong
producer template for the requested endpoint when accessing from multiple
threads
--
This message was sent by Atlassian Jira
(v8.20.10#820010)