from another thread:
If you continue to receive these errors, it may be simply down to some sort of corrupted image. To identify it, look in the xengallery_media table for the last entry.
In archived_import_log_xmg the last entry is the old_id 17998. In the source data the next id is 18001, the ids 17999 and 18000 are not present.
Is that a problem when the source data has gaps?