Websocket "race condition"

Hi everyone, sorry for the dumb question. But I am a newbie in elixir came from golang.

I really love elixir and FP style, I try to implement some basic feature and had an issue with race conditions on channel connection. For example, in golang I resolved it with Mutex, but it’s not FP style.

Initial problem:
Several channel connections, waiting for the group of random amount for example 5. And then randomly shuffle people. In this case, I had some problems with “race condition”. Same people to different groups etc.

What is the right idiomatic way to solve this in Elixir?

Thank you for your help. And sorry again for a dumb question.