public bool CanContinueBatch(QueryOperationContext queryContext, TransactionOperationContext indexingContext, IndexingStatsScope stats, IndexWriteOperation indexWriter, long currentEtag, long maxEtag, long count) { if (stats.Duration >= _configuration.MapTimeout.AsTimeSpan) { stats.RecordMapCompletedReason($"Exceeded maximum configured map duration ({_configuration.MapTimeout.AsTimeSpan}). Was {stats.Duration}"); return(false); } if (_configuration.MapBatchSize.HasValue && count >= _configuration.MapBatchSize.Value) { stats.RecordMapCompletedReason($"Reached maximum configured map batch size ({_configuration.MapBatchSize.Value:#,#;;0})."); return(false); } if (currentEtag >= maxEtag && stats.Duration >= _configuration.MapTimeoutAfterEtagReached.AsTimeSpan) { stats.RecordMapCompletedReason($"Reached maximum etag that was seen when batch started ({maxEtag:#,#;;0}) and map duration ({stats.Duration}) exceeded configured limit ({_configuration.MapTimeoutAfterEtagReached.AsTimeSpan})"); return(false); } if (_index.ShouldReleaseTransactionBecauseFlushIsWaiting(stats)) { return(false); } if (_index.CanContinueBatch(stats, queryContext, indexingContext, indexWriter, count) == false) { return(false); } return(true); }
public bool CanContinueBatch(IndexingStatsScope stats, long currentEtag, long maxEtag) { if (stats.Duration >= _configuration.MapTimeout.AsTimeSpan) { stats.RecordMapCompletedReason($"Exceeded maximum configured map duration ({_configuration.MapTimeout.AsTimeSpan}). Was {stats.Duration}"); return(false); } if (currentEtag >= maxEtag && stats.Duration >= _configuration.MapTimeoutAfterEtagReached.AsTimeSpan) { stats.RecordMapCompletedReason($"Reached maximum etag that was seen when batch started ({maxEtag}) and map duration ({stats.Duration}) exceeded configured limit ({_configuration.MapTimeoutAfterEtagReached.AsTimeSpan})"); return(false); } if (ShouldReleaseTransactionBecauseFlushIsWaiting(stats)) { return(false); } if (_index.CanContinueBatch(stats) == false) { return(false); } return(true); }
private bool ShouldReleaseTransactionBecauseFlushIsWaiting(IndexingStatsScope stats) { if (GlobalFlushingBehavior.GlobalFlusher.Value.HasLowNumberOfFlushingResources == false) { return(false); } var now = DateTime.UtcNow; if ((now - _lastCheckedFlushLock).TotalSeconds < 1) { return(false); } _lastCheckedFlushLock = now; var gotLock = _index._indexStorage.Environment().FlushInProgressLock.TryEnterReadLock(0); try { if (gotLock == false) { stats.RecordMapCompletedReason("Environment flush was waiting for us and global flusher was about to use all free flushing resources"); return(true); } } finally { if (gotLock) { _index._indexStorage.Environment().FlushInProgressLock.ExitReadLock(); } } return(false); }