in reply to Re^2: fetchrow_hashref failed problem
in thread fetchrow_hashref failed problem

Is RaiseError set? If you get the deadlock error, you should not fetch again, you should start the whole transaction over again.