add locking around table creating and modification

This is related to https://github.com/dimagi/fluff/pull/47