Deleting rows in google sheets using Google Apps Script

When a row is deleted from a sheet, the rows below it get renumbered even as the script continues to run. If the script subsequently tries to also delete those rows, the result is unpredictable. For this reason, when deleting rows one should proceed from bottom to top. In your case, like so:

for (var i = row_del.length - 1; i>=0; i--) {
  sheet.deleteRow(row_del[i]); 
}

refer to lock function suggested by google team:

  var lock = LockService.getScriptLock();
  lock.waitLock(30000); // lock 30 seconds
  //do whatever you want here
  lock.releaseLock();

That way, you got your deleting job work once at a time! The system thread won't go on to other jobs until 30 seconds is up or releasing the lock.

google dev-document: https://developers.google.com/apps-script/reference/lock/lock