fixed issue 1623:Storing tickets in DB will produce a deadlock on an internal error, thanks lumurer