272
273
// Record how many documents are waiting to be flushed to Elasticsearch after this bulk is committed.
274
>
p.metricsHandler.Histogram(metrics.ElasticsearchBulkProcessorQueuedRequests.Name(), metrics.ElasticsearchBulkProcessorBulkSize.Unit()).
processor.go
275
>
Record(int64(p.mapToAckFuture.Len()))
276
}
277
278
>
func (p *processorImpl) buildResponseIndex(response *elastic.BulkResponse) map[string]*elastic.BulkResponseItem {
processor.go
279
>
result := make(map[string]*elastic.BulkResponseItem)
280
>
for _, operationResponseItemMap := range response.Items {
281
>
for _, responseItem := range operationResponseItemMap {
282
>
existingResponseItem, duplicateID := result[responseItem.Id]
283
>
// In some rare cases, there might be duplicate document Ids in the same bulk.
284
>
// (for example, if two sequential upsert search attributes operation for the same workflow run end up being in the same bulk request)
285
>
// In this case, item with greater status code (error) will overwrite existing item with smaller status code.
286
>
if !duplicateID || existingResponseItem.Status < responseItem.Status {
287
>
result[responseItem.Id] = responseItem
288
>
}
289
}
290
}
292
}
293