When BulkProcessor retries failed item requests then the same `IndexRequest` instance are used in a new `BulkRequest` for a retry. This is a problem when `BulkProcessor` is used from within Elasticsearch (this is the case for deprecation index logging, ilm/slm history and more), because the bulk request transport action may have set the `autoGeneratedTimestamp` field. 

If that is the case then error such a these may appear in the logs and the `BulkProcessor` retry fails:

```
Bulk write of 1 deprecation logs failed: autoGeneratedTimestamp should not be set externally
java.lang.IllegalArgumentException: autoGeneratedTimestamp should not be set externally
	at org.elasticsearch.action.bulk.TransportBulkAction.doInternalExecute(TransportBulkAction.java:223) ~[elasticsearch-7.16.1.jar:7.16.1]
	at org.elasticsearch.action.bulk.TransportBulkAction$1.doRun(TransportBulkAction.java:192) ~[elasticsearch-7.16.1.jar:7.16.1]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) [elasticsearch-7.16.1.jar:7.16.1]
	at org.elasticsearch.action.bulk.TransportBulkAction.doExecute(TransportBulkAction.java:200) [elasticsearch-7.16.1.jar:7.16.1]
	at org.elasticsearch.action.bulk.TransportBulkAction.doExecute(TransportBulkAction.java:91) [elasticsearch-7.16.1.jar:7.16.1]
```

In the bulk transport action, for each bulk item request of the `BulkRequest` its `process()` method is invoked. Incase of `IndexRequest` when no _id has been specified an id is generated and in that case the `IndexRequest#autoGeneratedTimestamp ` field is set. If the bulk request fails at a later stage, for example because there was no capacity on the node that hosts a primary shard to index documents then the bulk response will contain a `EsRejectedExecutionException` exception in the `BulkResponse` for the bulk items this failure occurred for. This is normal behaviour. However the `BulkProcessor` has retry logic and `EsRejectedExecutionException` is deemed retry-able. The `BulkProcessor` [reuses the same bulk request item instances ](https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/bulk/Retry.java#L139)(`IndexRequest` in this case) upon retry. This causes the failure mentioned in the stack trace.
server/src/main/java/org/elasticsearch/action/index/IndexRequest.java
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentType;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import static org.elasticsearch.action.ValidateActions.addValidationError;
import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_PRIMARY_TERM;
import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO;
/**
 * Index request to index a typed JSON document into a specific index and make it searchable. Best
 * created using {@link org.elasticsearch.client.internal.Requests#indexRequest(String)}.
 *
 * The index requires the {@link #index()}, {@link #id(String)} and
 * {@link #source(byte[], XContentType)} to be set.
 *
 * The source (content to index) can be set in its bytes form using ({@link #source(byte[], XContentType)}),
 * its string form ({@link #source(String, XContentType)}) or using a {@link org.elasticsearch.xcontent.XContentBuilder}
 * ({@link #source(org.elasticsearch.xcontent.XContentBuilder)}).
 *
 * If the {@link #id(String)} is not set, it will be automatically generated.
 *
 * @see IndexResponse