Test setup:
Database with a single table with one row. The table just contains a single text column.
Test case:
foobarCan you create a small self-contained test-case?
You are running the nested transaction in a second connection, which is never going to work.
Also, your inner transaction is trying to update a row that does not exist, since it has never been inserted into the table.
The point is that you should not be spawning a child thread and
waiting for it while you have an open transaction. You should commit
the transaction before spawning the child thread.
This is because while a transaction is open that table is locked.
One simple thing you could try is just passing the connection into the
child thread so that the parent and child use the same connection.