neo-go/pkg/rpcclient
Pavel Karpy d6eaf6efc2 rpcclient/WS: fix data race on concurrent (un)subscription
Every client's (Un)Subscription call does two things: an RPC call and a
subscription map lock (two of maps currently). If we imagine that there is
one routine that tries to subscribe (A) and one routine that tries to
unsubscribe (B), the following sequence can happen:

0. Current number of subscriptions is X
1. B does an RPC and makes number of subscriptions X-1
2. A does an RPC and makes number of subscriptions X again
3. A holds subscription locks and rewrites client's subscription state
   (subscription with ID X now points to a different channel; channel that
   was registered by B is lost and is not related to any real subscription
   but is still included in the `receivers` map)
4. B holds subscription locks and drops subscription X (first, it is an
   error and we have just lost a subscription that we think was made
   successfully second, we have lost a channel in the `receivers` map, and
   no corresponding subscription points to it)
5. X subscription is received by the WS client (in practice it is a new
   block, 100ms, quite often to be sure this issue happens every hour), we
   range through the receivers, see no corresponding subscription, and
   panic.

Closes #3093.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2024-07-26 18:19:50 +03:00
..
actor rpcclient: refactor waiter package naming 2023-12-29 15:22:50 +03:00
gas native: autogenerate nativehashes package 2024-05-14 09:39:53 +03:00
invoker neorpc: fix exported structure comment 2023-10-20 19:31:23 +03:00
management native: autogenerate nativehashes package 2024-05-14 09:39:53 +03:00
neo native: autogenerate nativehashes package 2024-05-14 09:39:53 +03:00
nep11 smartcontract: drop standard events before RPC binging generation 2023-05-31 15:53:43 +03:00
nep17 smartcontract: drop standard events before RPC binging generation 2023-05-31 15:53:43 +03:00
neptoken *: replace interface{} with any keyword 2023-04-04 13:22:42 +03:00
nns smartcontract: update nns wrapper 2024-01-26 18:30:17 +03:00
notary *: use nativehashes package where possible 2024-04-25 13:26:54 +03:00
oracle native: autogenerate nativehashes package 2024-05-14 09:39:53 +03:00
policy native: autogenerate nativehashes package 2024-05-14 09:39:53 +03:00
rolemgmt native: autogenerate nativehashes package 2024-05-14 09:39:53 +03:00
unwrap unwrap: implement Exception type for better exception handling 2024-05-15 23:00:27 +03:00
waiter *: use multierror wrapping where possible 2024-03-05 13:54:10 +03:00
client.go *: replace go.uber.org/atomic with sync/atomic 2023-10-12 17:59:34 +03:00
client_test.go rpcclient: expose endpoint (fixes #2912) 2023-02-15 08:29:44 +01:00
doc.go docs: canceltransaction is not going to be supported 2023-11-21 16:11:58 +03:00
doc_test.go rpcclient: use better RPC endpoint for example 2024-02-26 23:18:45 +03:00
local.go rpcclient: fix #3135 wsclient hangs on making request 2023-10-16 13:01:12 +03:00
local_test.go rpcclient: add Internal client for direct RPC server calls 2023-02-16 23:49:58 +03:00
rpc.go state: drop NativeContract, fix #3430 2024-05-16 18:46:46 +03:00
rpc_test.go rpcsrv: add SessionEnabled, MaxIteratorResultItems to getversion 2024-04-03 22:42:14 +03:00
wsclient.go rpcclient/WS: fix data race on concurrent (un)subscription 2024-07-26 18:19:50 +03:00
wsclient_test.go *: adjust WS connection RW deadlines 2024-04-02 10:31:38 +03:00