Add hostname to "pid".
Sleep wait to retry getting the table.

Raise LockError if it fails after 10 attempts.
Continue waiting until table is created.

Notice s/unless/while/.