Re: Lock wait timeout exceeded; try restarting transaction
Sounds like you are learning fast about indexes, vertical partitioning, etc. :)
Do you have autocommit OFF? It should be ON, or (even better) you should take control of the transactions with explicit BEGIN...COMMIT statements. Here's my theory: You have autocommit=0 and do some query (even a SELECT); then that connection sits around for more than 50 seconds. Meanwhile, other processes are blocking (sometimes).
I should have thought about TRUNCATE.
You only want the bottom layer, correct? Not all the 'family'.
I don't know why my suggestion failed. See if this change makes a diff:
select @c := eid
-->
select eid INTO @c