...
A) If this attempt fails, the retry mechanism should be started (parameters for the retry mechanism are stored in mod-configuration). If a lock wasn't acquired even with the retry mechanism, 503 422 Error should be returned with an appropriate message. No permanent changes or signals to other modules suggesting a successful check-out should be made, which means:
...
The critical block of operations where race conditions should be avoided includes loan limits validation, update of the item and creation of the loan; other operations, e.g. notifications, could be done without locking. Performance impact on overall process should be negligible as overhead introduced by lock mechanism only includes two insert/delete operations and the critical block performs under 500ms according to performance test results for checkout.