db-functions: fix locking issues due to all locks share the same fd
Calling acquire_fd
in a subshell doesn't populate the global lockfd
associate array properly. Let's use return code to pass the value to
avoid the subshell.
Fixes locking issues with db-update where a subsequence unlock on a different lock will release the first lock guard of the whole operation because all locks always reuse the same fd due to this bug.