Program: 13099
Project: 13099
Buggy source:
private void deletePartitionWhileInsertingData(final boolean useBulk) throws Exception {
  execute("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  ensureYellow();
  int numberOfDocs=1000;
  final Object[][] bulkArgs=new Object[numberOfDocs][];
  for (int i=0; i < numberOfDocs; i++) {
    bulkArgs[i]=new Object[]{i % 2,randomAsciiOfLength(10)};
  }
  final int idToDelete=1;
  final AtomicReference<Exception> exceptionRef=new AtomicReference<>();
  final CountDownLatch insertLatch=new CountDownLatch(1);
  final String insertStmt="String_Node_Str";
  Thread insertThread=new Thread(new Runnable(){
    @Override public void run(){
      try {
        if (useBulk) {
          execute(insertStmt,bulkArgs);
        }
 else {
          for (          Object[] args : bulkArgs) {
            execute(insertStmt,args);
          }
        }
      }
 catch (      Exception t) {
        exceptionRef.set(t);
      }
 finally {
        insertLatch.countDown();
      }
    }
  }
);
  final CountDownLatch deleteLatch=new CountDownLatch(1);
  final String partitionName=new PartitionName("String_Node_Str",Collections.singletonList(new BytesRef(String.valueOf(idToDelete)))).asIndexName();
  final Object[] deleteArgs=new Object[]{idToDelete};
  Thread deleteThread=new Thread(new Runnable(){
    @Override public void run(){
      boolean deleted=false;
      while (!deleted) {
        try {
          MetaData metaData=client().admin().cluster().prepareState().execute().actionGet().getState().metaData();
          if (metaData.indices().get(partitionName) != null) {
            execute("String_Node_Str",deleteArgs);
            deleted=true;
          }
        }
 catch (        Throwable t) {
        }
      }
      deleteLatch.countDown();
    }
  }
);
  insertThread.start();
  deleteThread.start();
  deleteLatch.await(SQLTransportExecutor.REQUEST_TIMEOUT.getSeconds() + 1,TimeUnit.SECONDS);
  insertLatch.await(SQLTransportExecutor.REQUEST_TIMEOUT.getSeconds() + 1,TimeUnit.SECONDS);
  Exception exception=exceptionRef.get();
  if (exception != null) {
    throw exception;
  }
  insertThread.join();
  deleteThread.join();
}

Fixed version (ground truth):
private void deletePartitionWhileInsertingData(final boolean useBulk) throws Exception {
  execute("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  int numberOfDocs=100;
  final Object[][] bulkArgs=new Object[numberOfDocs][];
  for (int i=0; i < numberOfDocs; i++) {
    bulkArgs[i]=new Object[]{i % 2,randomAsciiOfLength(10)};
  }
  final int idToDelete=1;
  final AtomicReference<Exception> exceptionRef=new AtomicReference<>();
  final CountDownLatch insertLatch=new CountDownLatch(1);
  final String insertStmt="String_Node_Str";
  Thread insertThread=new Thread(new Runnable(){
    @Override public void run(){
      try {
        if (useBulk) {
          execute(insertStmt,bulkArgs);
        }
 else {
          for (          Object[] args : bulkArgs) {
            execute(insertStmt,args);
          }
        }
      }
 catch (      Exception t) {
        exceptionRef.set(t);
      }
 finally {
        insertLatch.countDown();
      }
    }
  }
);
  final CountDownLatch deleteLatch=new CountDownLatch(1);
  final String partitionName=new PartitionName("String_Node_Str",Collections.singletonList(new BytesRef(String.valueOf(idToDelete)))).asIndexName();
  final Object[] deleteArgs=new Object[]{idToDelete};
  Thread deleteThread=new Thread(new Runnable(){
    @Override public void run(){
      boolean deleted=false;
      while (!deleted) {
        try {
          MetaData metaData=client().admin().cluster().prepareState().execute().actionGet().getState().metaData();
          if (metaData.indices().get(partitionName) != null) {
            execute("String_Node_Str",deleteArgs);
            deleted=true;
          }
        }
 catch (        Throwable t) {
        }
      }
      deleteLatch.countDown();
    }
  }
);
  insertThread.start();
  deleteThread.start();
  deleteLatch.await(SQLTransportExecutor.REQUEST_TIMEOUT.getSeconds() + 1,TimeUnit.SECONDS);
  insertLatch.await(SQLTransportExecutor.REQUEST_TIMEOUT.getSeconds() + 1,TimeUnit.SECONDS);
  Exception exception=exceptionRef.get();
  if (exception != null) {
    throw exception;
  }
  insertThread.join();
  deleteThread.join();
}