Calling maapi_apply_trans() function is failing when another transaction is already going on

Deadlock?
See for example this topic.