One of the reason for WFENG_COMMIT_INSIDE error is workflow engine detect the commit in the program called from the worlflow process.
Workflow user guide clearly says that we should not put commit or rollback in API code called from workflow process.
If your workflow activity stuck , then you can try to progress the workflow by either RETRY (if you want to execute the underliying code ) or SKIP (if you want to skip the inderlying code).API for that is WF_ENGINE.HANDLE_ERROR.
For more Info on Workflow , please refer
To refer how to design a Master Detail Workflow