RTS is not properly handling when insert and remove operations both are done under a single prepared transaction and they are written to disk. As part of aborting these updates by RTS when the prepared timestamp is less than the stable timestamp, it only aborts the remove operation and retains insert operation done by the prepared transaction.
Due to which the uncommitted prepared insert is retained on the disk lead to the duplicate key failure when the same key gets inserted again.