You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Igor Sapego (Jira)" <ji...@apache.org> on 2021/01/14 16:49:00 UTC
[jira] [Updated] (IGNITE-13997) CPP Thin: Transactions can cause
deadlock when client shared in multiple threads
[ https://issues.apache.org/jira/browse/IGNITE-13997?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Sapego updated IGNITE-13997:
---------------------------------
Description:
In our tests we have detected a deadlock when following piece of code is
executed for more than one thread on our application:
{code:cpp}
ClientTransactions transactions = client.ClientTransactions();
ClientTransaction tx = transactions.TxStart(PESSIMISTIC, READ_COMMITTED);
// This call should atomically get the current value for "key" and put
"value" instead, locking the "key" cache entry at the same time
auto oldValue = cache.GetAndPut(key, value);
// Only the thread able of locking "key" should reach this code. Others have
to wait for tx.Commit() to complete
cache.Put (key, newValue);
// After this call, other thread waiting in GetAndPut for "key" to be
released should be able of continuing
tx.Commit ();
{code}
The thread reaching "cache.Put (key, newValue);" call, gets blocked in
there, concretely in the lockGuard object created at the beginning of
DataChannel::InternalSyncMessage function (data_channel.cpp:108). After
debugging, we realized that this lockGuard is owned by a different thread,
which is currently waiting on socket while executing GetAndPut function.
According to this, my guess is that data routing for C++ Thin Clients is not
multithread friendly.
Reported in http://apache-ignite-users.70518.x6.nabble.com/Multithread-transactions-in-a-C-Thin-Client-td35145.html
was:
In our tests we have detected a deadlock when following piece of code is
executed for more than one thread on our application:
{code:cpp}
ClientTransactions transactions = client.ClientTransactions();
ClientTransaction tx = transactions.TxStart(PESSIMISTIC, READ_COMMITTED);
// This call should atomically get the current value for "key" and put
"value" instead, locking the "key" cache entry at the same time
auto oldValue = cache.GetAndPut(key, value);
// Only the thread able of locking "key" should reach this code. Others have
to wait for tx.Commit() to complete
cache.Put (key, newValue);
// After this call, other thread waiting in GetAndPut for "key" to be
released should be able of continuing
tx.Commit ();
{code:cpp}
The thread reaching "cache.Put (key, newValue);" call, gets blocked in
there, concretely in the lockGuard object created at the beginning of
DataChannel::InternalSyncMessage function (data_channel.cpp:108). After
debugging, we realized that this lockGuard is owned by a different thread,
which is currently waiting on socket while executing GetAndPut function.
According to this, my guess is that data routing for C++ Thin Clients is not
multithread friendly.
Reported in http://apache-ignite-users.70518.x6.nabble.com/Multithread-transactions-in-a-C-Thin-Client-td35145.html
> CPP Thin: Transactions can cause deadlock when client shared in multiple threads
> --------------------------------------------------------------------------------
>
> Key: IGNITE-13997
> URL: https://issues.apache.org/jira/browse/IGNITE-13997
> Project: Ignite
> Issue Type: Bug
> Components: thin client
> Affects Versions: 2.9.1
> Reporter: Igor Sapego
> Priority: Major
>
> In our tests we have detected a deadlock when following piece of code is
> executed for more than one thread on our application:
> {code:cpp}
> ClientTransactions transactions = client.ClientTransactions();
> ClientTransaction tx = transactions.TxStart(PESSIMISTIC, READ_COMMITTED);
> // This call should atomically get the current value for "key" and put
> "value" instead, locking the "key" cache entry at the same time
> auto oldValue = cache.GetAndPut(key, value);
> // Only the thread able of locking "key" should reach this code. Others have
> to wait for tx.Commit() to complete
> cache.Put (key, newValue);
> // After this call, other thread waiting in GetAndPut for "key" to be
> released should be able of continuing
> tx.Commit ();
> {code}
> The thread reaching "cache.Put (key, newValue);" call, gets blocked in
> there, concretely in the lockGuard object created at the beginning of
> DataChannel::InternalSyncMessage function (data_channel.cpp:108). After
> debugging, we realized that this lockGuard is owned by a different thread,
> which is currently waiting on socket while executing GetAndPut function.
> According to this, my guess is that data routing for C++ Thin Clients is not
> multithread friendly.
> Reported in http://apache-ignite-users.70518.x6.nabble.com/Multithread-transactions-in-a-C-Thin-Client-td35145.html
--
This message was sent by Atlassian Jira
(v8.3.4#803005)