Cache complete refresh fails with `application.batchSize` > 1000 and Non-Multiples of 1000
Description:
The batch processing algorithm fails when application.batchSize
is configured with a value greater than 1000 and that value is not a multiple of 1000.
-
Working cases:
- Batch sizes less than 1000 (e.g., 123, 889) work correctly.
- Batch sizes that are multiples of 1000 (e.g., 1000, 2000, 3000) also work.
-
Failing cases:
- Batch sizes greater than 1000 and non-multiples of 1000 (e.g., 1001, 1234, 2345) lead to incomplete processing or failures.
Issue Location:
The issue is located in the Search#queryRecordsInBatch
method. The following code is responsible for starting the incorrect behavior:
int limit = 1000;
if (batchSize < limit) {
limit = batchSize;
}
This piece of logic sets the limit
based on batchSize
, which then leads to incorrect calculations and failures when batchSize
is greater than 1000 but not a multiple of 1000.
Steps to Reproduce:
- Set
application.batchSize
to any value > 1000 that is not a multiple of 1000 (e.g., 1234). - Trigger a cache update (e.g.
{{AMBASSADOR_URL}}/updateCacheForSingle?cacheName=Well
). - Trace logs. Observe that the process fails or does not handle all records correctly.
Expected Result:
The algorithm should handle any batchSize
> 1000, including non-multiples of 1000, without errors.
Actual Result:
Non-multiples of 1000 as batchSize
result in failures or incomplete processing.