In 4.0.8, we will make better use of INSERT ... ON DUPLICATE UPDATE instead of REPLACE wherever possible. This should reduce the potential for deadlocks in the future. Sometimes it is unavoidable, though; with multiple row updates on multi-column indexes it is not always possible to use UPDATE CASE clauses with non-ambiguity, thus REPLACE is generally used to work around race conditions associated with INSERT.