fix: scan manager scan limit should reset each invocation #374
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is currently a bug in scan manager. When running a scan or find operation without
totalSegments
and withlimit
in the ScanOptions, theitemsFetchedSoFarTotalParallelCount
variable is updated with the number of items scanned but is not reset to 0.This results in no items being scanned in subsequent calls to the scan (or find) method.
Example:
The existing implementation of
parallelScan
correctly starts by setting the variable to 0 while the implementation ofscan
does not:this.scan
is called (multiple times) from withinparallelScan
, thus we can't just add athis.itemsFetchedSoFarTotalParallelCount = 0;
at the start ofscan
, rather I migrated the existingscan
method to an internal_scan
method. The new_scan
method is unchanged from the originalscan
method, and the updated (public)scan
method callsthis.itemsFetchedSoFarTotalParallelCount = 0;
followed by calling_scan
.This leaves the
parallelScan
working as it currently does, and fixes the issue when using the normalscan
method.(First time contributing here, thank you so much for the awesome library! Let me know if any changes are needed to get this pr approved. Thanks!)