Apply pattern matching to ensure only locking issue can be catched