bruno-roustant commented on code in PR #2021:
URL: https://github.com/apache/solr/pull/2021#discussion_r1364255196
##########
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:
That would be actually the same, as highest can only increase in
VersionBucket.
Here highestVersionSeed is updated with the max to seed the next
VersionBucket to create. If highestVersionSeed was set to highestVersion, it
could potentially decrease.
--
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]