Fix theoretical swallow of SQLException when attempting to acquire a lock and possible NPE [RTFACT-22339]

external_document