This was caused by a dodgy index on the table. Now the index has been corrected, the error no longer happens.