steep-computer-92756
11/28/2025, 12:02 PMtall-airline-16756
11/28/2025, 12:02 PMtall-airline-16756
11/28/2025, 12:02 PMCreateRoom calls can produce multiple active rooms with the same room name due to race conditions. Here are practical ways to prevent that, and which to choose depending on your needs.
What’s happening
• LiveKit does not enforce global uniqueness of room names, so simultaneous CreateRoom requests can each succeed and create separate rooms (only the Room SID is guaranteed unique).
Recommended options
• Let rooms be auto-created on participant join (best): don't call CreateRoom manually. LiveKit will create the room when the first participant connects with a valid token, which removes the race entirely.
• Use external synchronization (when you must call CreateRoom): acquire a distributed lock per room name (Redis, database row lock, etc.) so only one request creates the room.
• Make room names unique: append a timestamp, UUID, or counter to the name to avoid collisions if coordination is difficult.
If you want, I can:
• Show a short pattern for using a Redis lock around CreateRoom.
• Outline how to switch to auto-creation and issue tokens for first-join behavior.
Which would you prefer?
Sources: Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | CreateRoom() is Taking Too Long