I run a python script from SQL Agent that deletes and rebuilds a layer so I subsequently add the indexes back on. It failed on a process after the index, so I started the script from the beginning as I had no legible error code. Thus it failed this time on the index rebuild. I reordered a bit of the python script and made the index part it's own module which is run last. Therefore if it fails I don't have to trouble shoot that aspect.