github.com/nats-io/nats-server/v2@v2.11.0-preview.2/locksordering.txt (about) 1 Here is the list of some established lock ordering. 2 3 In this list, A -> B means that you can have A.Lock() then B.Lock(), not the opposite. 4 5 jetStream -> jsAccount -> Server -> client -> Account 6 7 jetStream -> jsAccount -> stream -> consumer 8 9 A lock to protect jetstream account's usage has been introduced: jsAccount.usageMu. 10 This lock is independent and can be invoked under any other lock: jsAccount -> jsa.usageMu, stream -> jsa.usageMu, etc... 11 12 A lock to protect the account's leafnodes list was also introduced to 13 allow that lock to be held and the acquire a client lock which is not 14 possible with the normal account lock. 15 16 accountLeafList -> client 17 18 AccountResolver interface has various implementations, but assume: AccountResolver -> Server 19 20 A reloadMu lock was added to prevent newly connecting clients racing with the configuration reload. 21 This must be taken out as soon as a reload is about to happen before any other locks: 22 23 reloadMu -> Server 24 reloadMu -> optsMu