I have some unmanaged code that creates child records to be attached to a Lead record after insert. Unfortunately, my org contains some managed code that also runs on a Lead after insert, and it's imperative for the unmanaged code to run before the managed. With that said, I know the order in which triggers execute on the same object for a given event is undefined.
My question pertains to the scenario where the managed trigger fires first. The managed code looks for duplicate records based on set criteria and merges the two if one is found. The existing record will always be the master and the incoming Lead will be deleted.
What can I expect to happen in the unmanaged after insert trigger that fires after the managed trigger has deleted the record? Is it even executed at all? Will the deleted records have their MasterRecordId set to the ID of the surviving record?