fix bug in allocating table id with lock