stillalex commented on code in PR #2021:
URL: https://github.com/apache/solr/pull/2021#discussion_r1364231225
##########
solr/core/src/java/org/apache/solr/update/VersionInfo.java:
##########
@@ -284,12 +344,28 @@ public Long getMaxVersionFromIndex(IndexSearcher
searcher) throws IOException {
}
public void seedBucketsWithHighestVersion(long highestVersion) {
- for (int i = 0; i < buckets.length; i++) {
- // should not happen, but in case other threads are calling
updateHighest on the version
- // bucket
- synchronized (buckets[i]) {
- if (buckets[i].highest < highestVersion) buckets[i].highest =
highestVersion;
+ // Sets the highest version on existing buckets only
+ synchronized (bucketsSync) {
+ if (bucketMap != null) {
+ bucketMap.forEach(
+ (IntObjectProcedure<VersionBucket>)
+ (i, bucket) -> {
+ // Should not happen, but synchronize in case other threads
are calling
+ // updateHighest on the version bucket.
+ synchronized (bucket) {
+ bucket.setHighestIfGreater(highestVersion);
+ }
+ });
+ } else {
+ for (VersionBucket bucket : bucketArray) {
+ if (bucket != null) {
+ synchronized (bucket) {
+ bucket.setHighestIfGreater(highestVersion);
+ }
+ }
+ }
}
+ highestVersionSeed = Math.max(highestVersion, highestVersionSeed);
Review Comment:
honestly trying to wrap my head around the use of bucket's internal version.
why wouldn't all the buckets get updated to this `max(highestVersion,
highestVersionSeed)` instead of `highestVersion`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]