protect channel id allocation with lock