LCL (Lock Chain Length), an elegant and generally applicable algorithm for resource deadlock detection and resolution in distributed environments without a restriction.
It's been implemented in OceanBase which is a distributed database system.
Here is the demo code of LCL.