Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit e16b7f8

Browse files
authored
fix newPendingTransactions subscription deadlock issue (#933)
1 parent 7b22a53 commit e16b7f8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
7878
* (evm) [tharsis#871](https://github.com/tharsis/ethermint/pull/871) Set correct nonce in `EthCall` and `EstimateGas` grpc query.
7979
* (rpc) [tharsis#878](https://github.com/tharsis/ethermint/pull/878) Workaround to make GetBlock RPC api report correct block gas used.
8080
* (rpc) [tharsis#900](https://github.com/tharsis/ethermint/pull/900) newPendingTransactions filter return ethereum tx hash.
81+
* (rpc) [tharsis#933](https://github.com/tharsis/ethermint/pull/933) Fix newPendingTransactions subscription deadlock when a Websocket client exits without unsubscribing and the node errors.
8182

8283
## [v0.9.0] - 2021-12-01
8384

rpc/websockets.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,16 @@ func (api *pubSubAPI) subscribePendingTransactions(wsConn *wsConn) (rpc.ID, erro
712712
api.logger.Debug("error writing header, will drop peer", "error", err.Error())
713713

714714
try(func() {
715+
// Release the initial read lock in .RUnlock() before
716+
// invoking .Lock() to avoid the deadlock in
717+
// https://github.com/tharsis/ethermint/issues/821#issuecomment-1033959984
718+
// and as documented at https://pkg.go.dev/sync#RWMutex
719+
api.filtersMu.RUnlock()
715720
api.filtersMu.Lock()
716-
defer api.filtersMu.Unlock()
721+
defer func() {
722+
api.filtersMu.Unlock()
723+
api.filtersMu.RLock()
724+
}()
717725

718726
if err != websocket.ErrCloseSent {
719727
_ = wsSub.wsConn.Close()

0 commit comments

Comments
 (0)