Fatal error : concurrent map read and write

Hello everyone,

I am currently running a game server (similar to Metin/mmorpg style) on a dedicated server from Hetzner.

It ran fine for about 1 month with an average of 25 players online.

Recently, more players have joined (45-50 in total now) and I keep getting crashes (fatal error : concurrent map read and write).

These did not happen with a smaller player base, I have added sync.RWmutexes and all that in the code and I still get random crashes.

The environment is highly concurrent.

I am running :

  • ryzen 7 7700
  • 64 gb ram
  • 512 gb nvme
  • 1gb/s bandwidth

The CPU is always under 20%.

Should I upgrade it?

Thanks

What is the actual panic? Can you recover/get a stack trace? You should for sure try to troubleshoot the error. It is extremely unlikely that more hardware would fix a concurrency problem. Here’s a relevant Stack Overflow question:

You could try a sync.Map (depending on your use case):

Also have you used the race detector?

1 Like

Indicates that some map reads and writes are not guarded by a mutex.

You may want to try replacing the map with the updated concurrent map in 1.24rc2 or check all of your map access and ensure that it is guarded with a rw mutex.

Check the map variable about read and write
try use sync.(RW)Mutex