한국어English日本語简体中文繁體中文DeutschไทยTiếng ViệtРусскийPortuguês (Brasil)EspañolBahasa Indonesia

Game Lag White Paper › L9 Server game process

Deadlock Deadlock

Cause ID sp-deadlock · Primary owner Game team (Server development)

Open the interactive card with figures and simulations →

When two threads each wait for a lock the other holds, both stop forever.

Why Thread A holds lock 1 and waits for lock 2, while B holds lock 2 and waits for lock 1 → Effect Both stop forever, and related threads stop one after another → On screen The whole server stops, and everyone disconnects when the watchdog restarts it

Symptoms
Freeze, Disconnect
Factors
Stall
Who’s affected
Whole server, One feature only
When
Randomly, When crowds gather
Owner
Primary owner Game team (Server development)
Game team action items
Set lock ordering rules, use locks with timeouts, add a watchdog that captures a thread dump at the moment of the hang.
On the graph
Mass disconnect · Connection count, server outbound traffic
Where to look
Call stacks of every thread captured during the hang: jstack for the JVM (finds and flags deadlocks automatically), dotnet-stack for .NET, gdb’s thread apply all bt for native servers, or dump a core file with gcore, restart, and analyze it afterward
Confirmed if
Two or more threads are stuck with stacks waiting for locks held by each other, and process CPU utilization is near 0 the whole time
Ruled out if
One thread spinning at 100% CPU during the hang: infinite loop. Threads waiting on DB or external responses: points to blocking calls or thread pool exhaustion
Check with
Infra tools (no game code needed)

Sources

  1. Runtime locking correctness validator Linux kernel
    Taking two locks in opposite orders causes circular waiting and a deadlock (lock inversion deadlock); the Linux kernel checks lock ordering and warns in advance
  2. Liveness, Readiness, and Startup Probes Kubernetes
    A liveness probe catches a deadlock, where the app is running but can’t make progress, and restarts the container
  3. Diagnostic Tools (Java SE 21 Troubleshooting Guide) Oracle
    jstack prints the stacks of all threads in a running JVM and also finds and flags deadlocks (Found one Java-level deadlock)
  4. dotnet-stack diagnostic tool - .NET CLI Microsoft
    Captures and prints the managed stacks of all threads in a .NET process
  5. Threads (Debugging with GDB) GNU Project
    thread apply all runs the same command (bt: print the call stack) on every thread
  6. gcore(1) — Linux manual page gdb
    Creates a core file of a running program, and the program keeps running afterward

See also

Same layer: L9 Server game process

Same symptom (Freeze), other layers

View the interactive card with figures and simulations