go-socket.io icon indicating copy to clipboard operation
go-socket.io copied to clipboard

Redis Broadcast - Locking Bug

Open steve-gray opened this issue 3 years ago • 2 comments

Describe the bug Under concurrent publishes/broadcasts, joins and leave, the redis adapter can hang, preventing all subsequent operations.

To Reproduce Can't provide a simple example owing to being integrated into our app, but we end up with about a dozen goroutines locking in various places. If you're publishing fairly large messages, the odds of hitting this scenario do seem higher.

Additional context Example goroutine stack - this routine has been stuck for several minutes. No clear goroutine that was the one that took the lock though, so guessing it's somewhere buried deep.

1 @ 0x439f85 0x44a925 0x44a90e 0x46b867 0x486f25 0x488690 0x488622 0xcf36be 0xcf6e33 0xcf6e14 0xced808 0xcf6f25 0x4873ac 0xcedcd9 0xcedc6a 0xcef7a6 0x46f601
#	0x46b866	sync.runtime_SemacquireMutex+0x46					/opt/go/src/runtime/sema.go:71
#	0x486f24	sync.(*Mutex).lockSlow+0x104						/opt/go/src/sync/mutex.go:138
#	0x48868f	sync.(*Mutex).Lock+0x8f							/opt/go/src/sync/mutex.go:81
#	0x488621	sync.(*RWMutex).Lock+0x21						/opt/go/src/sync/rwmutex.go:98
#	0xcf36bd	github.com/googollee/go-socket%2eio.(*redisBroadcast).LeaveAll+0x5d	/go/src/ourapp/sockets/vendor/github.com/googollee/go-socket.io/redis_broadcast.go:334
#	0xcf6e32	github.com/googollee/go-socket%2eio.(*namespaceConn).LeaveAll+0x52	/go/src/ourapp/sockets/vendor/github.com/googollee/go-socket.io/namespace_conn.go:101
#	0xcf6e13	github.com/googollee/go-socket%2eio.(*conn).Close.func1.1+0x33		/go/src/ourapp/sockets/vendor/github.com/googollee/go-socket.io/conn.go:115
#	0xced807	github.com/googollee/go-socket%2eio.(*namespaces).Range+0xe7		/go/src/ourapp/sockets/vendor/github.com/googollee/go-socket.io/conn.go:68
#	0xcf6f24	github.com/googollee/go-socket%2eio.(*conn).Close.func1+0x64		/go/src/ourapp/sockets/vendor/github.com/googollee/go-socket.io/conn.go:114

steve-gray avatar Mar 18 '21 09:03 steve-gray

Hey, @steve-gray Do you can share fragment your call code when you met this error?

sshaplygin avatar May 11 '21 16:05 sshaplygin

This bug still exists in the latest v1.6.0. After using the redis adapter for about 12 hours, the websocket is completely stuck and cannot be used. Until execute redis command "CLIENT KILL TYPE normal" , it worked again.

ahkimkoo avatar Dec 16 '21 11:12 ahkimkoo