[SalesForce] DELETE_OPERATION_TOO_LARGE, Cascade deleting too many records

I have 4 custom objects which has master-detail relationship with each other.

Obj A (Parent)

|

Obj B (Child of Obj A)

|

Obj C (Child of Obj B)

|

Obj D (Child of Obj C)

So if I delete Obj A , all the child records of these objects has to be deleted. But I face an issue when I try to delete an Obj A record which has large number of child records.The error is "Delete failed. First exception on row 0 with id "Id of the record"; first error: DELETE_OPERATION_TOO_LARGE, Cascade deleting too many records: occurring when cascading to Obj D records: []"

I tried to empty the recycle bin by calling Database.emptyRecycleBin(List ObjArecords) after deleting but still the above error occurs.

Is there any way to rectify this issue.? How will I delete all these records?

Best Answer

If you're running in to this issue, you'll have to delete the "D" records first and work your way back up to the top. This will require asynchronous code, because the limit is an absolute limit per transaction, and is far greater than you can delete directly (50,000 cascade deletes versus 10,000 direct deletes).