MySql Gap Lock Deadlock on Inserts
I'm not a MySQL expert, but by the look of your Deadlock logs, even though you are INSERTing different vehicle IDs per statement, those require the whole datapage (238326) of the VehicleID
non-clustered index to be locked.
The fact you are occasionally getting deadlocks means that within 1 page you have multiple vehicle IDs, so there is a small chance that 2 different processes will need a lock for the same page.
Best thing to advise is to keep your transactions as small as possible.
If there is some way you can do the following, it'll help lessen the chance of a deadlock:
START TRANSACTION;
UPDATE vehicle_image SET active = 0 WHERE vehicleID = SOMEID and active = 1;
END TRANSACTION;
Loop:
START TRANSACTION;
INSERT INTO vehicle_image (vehicleID, vehicleImageFilePath,
vehicleImageSplashFilePath, vehicleImageThumbnailFilePath,
vehicleImageMiniFilePath, mainVehicleImage, active)
VALUES (%s, %s, %s, %s, %s, %s, 1);
END TRANSACTION;
--EndLoop here
If you can, try to change that index's fill factor to 95%, and test to see if you get fewer deadlocks.
A more extreme test would be to remove that index completely while INSERTing, then recreate it when done.