Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1ea5cce
Add merge policy to block older segments from participating in merges
rahulgoswami Nov 20, 2025
cdc9978
extend FilterMergePolicy for delegation and modularize logic
rahulgoswami Nov 26, 2025
4be5ca1
First draft: Add UPGRADECOREINDEX as a CoreAdmin API
rahulgoswami Nov 30, 2025
052cda6
fix incorrect early-exit while iterating over segments
rahulgoswami Nov 30, 2025
faff01f
merge with main
rahulgoswami Dec 9, 2025
c9e3f3e
restore original merge policy; injectable factory for test stubs; opt…
rahulgoswami Dec 12, 2025
daaaecb
cleanup and optimizations
rahulgoswami Dec 12, 2025
1fa4f2a
more cleanup
rahulgoswami Dec 12, 2025
de455df
get default update chain if update.chain is not defined for /update
rahulgoswami Dec 13, 2025
c98418b
fix getUpdateProcessorChain()
rahulgoswami Dec 14, 2025
57b5842
gradlew tidy
rahulgoswami Dec 14, 2025
abd584e
fix getUpdateProcessorChain()
rahulgoswami Dec 14, 2025
bdfa291
1) incorrect LeafReader closure.2) Fix validation
rahulgoswami Dec 21, 2025
feb70ac
cleanup
rahulgoswami Dec 21, 2025
393c081
interrupt handling and validation cleanup
rahulgoswami Dec 22, 2025
b335e8e
async mode may cause merge policy to be reset immediately
rahulgoswami Dec 23, 2025
6a354fd
Fix null response
rahulgoswami Dec 23, 2025
088c599
changelog
rahulgoswami Dec 29, 2025
dfd7786
Merge branch 'main' into index-upgrade since LatestVersionMergePolicy…
rahulgoswami Dec 30, 2025
3655ef4
LatestVersionMergePolicy renamed
rahulgoswami Dec 30, 2025
a50fc8d
Fix issue with running in async mode
rahulgoswami Dec 30, 2025
3607110
Decorate response with bookkeeping info and upgrade state
rahulgoswami Dec 31, 2025
0f10339
Wrap exceptions in CoreAdminAPIBaseException
rahulgoswami Jan 1, 2026
b8b5deb
Wrap exceptions in CoreAdminAPIBaseException
rahulgoswami Jan 1, 2026
983f2d6
Handle exceptions in processSegment to preserve the main failure
rahulgoswami Jan 2, 2026
d005712
keeping validateLogCalls and forbidden apis check happy
rahulgoswami Jan 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
title: CoreAdmin API (/admin/cores?action=UPGRADECOREINDEX) to upgrade an index in-place
type: added
authors:
- name: Rahul Goswami
links:
- name: SOLR-17725
url: https://issues.apache.org/jira/browse/SOLR-17725

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.apache.solr.client.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

public class UpgradeCoreIndexRequestBody {

@Schema(description = "Request ID to track this action which will be processed asynchronously.")
@JsonProperty
public String async;

@JsonProperty public String updateChain;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.apache.solr.client.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

public class UpgradeCoreIndexResponse extends SolrJerseyResponse {
@Schema(description = "The name of the core.")
@JsonProperty
public String core;

@Schema(description = "The total number of segments eligible for upgrade.")
@JsonProperty
public Integer numSegmentsEligibleForUpgrade;

@Schema(description = "The number of segments successfully upgraded.")
@JsonProperty
public Integer numSegmentsUpgraded;

@Schema(description = "Status of the core index upgrade operation.")
@JsonProperty
public String upgradeStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.STATUS;
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.SWAP;
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.UNLOAD;
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.UPGRADECOREINDEX;
import static org.apache.solr.handler.admin.CoreAdminHandler.CallInfo;

import java.lang.invoke.MethodHandles;
Expand Down Expand Up @@ -256,7 +257,8 @@ public enum CoreAdminOperation implements CoreAdminOp {
final ListCoreSnapshotsResponse response = coreSnapshotAPI.listSnapshots(coreName);

V2ApiUtils.squashIntoSolrResponseWithoutHeader(it.rsp, response);
});
}),
UPGRADECOREINDEX_OP(UPGRADECOREINDEX, new UpgradeCoreIndexOp());

final CoreAdminParams.CoreAdminAction action;
final CoreAdminOp fun;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.apache.solr.handler.admin;

import org.apache.solr.client.api.model.UpgradeCoreIndexRequestBody;
import org.apache.solr.client.api.model.UpgradeCoreIndexResponse;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.handler.admin.api.UpgradeCoreIndex;
import org.apache.solr.handler.api.V2ApiUtils;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;

public class UpgradeCoreIndexOp implements CoreAdminHandler.CoreAdminOp {
@FunctionalInterface
public interface UpgradeCoreIndexFactory {
UpgradeCoreIndex create(
CoreContainer coreContainer,
CoreAdminHandler.CoreAdminAsyncTracker coreAdminAsyncTracker,
SolrQueryRequest req,
SolrQueryResponse rsp);
}

static UpgradeCoreIndexFactory UPGRADE_CORE_INDEX_FACTORY = UpgradeCoreIndex::new;

@Override
public boolean isExpensive() {
return true;
}

@Override
public void execute(CoreAdminHandler.CallInfo it) throws Exception {

assert it.handler.coreContainer != null;
if (it.handler.coreContainer.isZooKeeperAware()) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"action=UPRGADECOREINDEX is not supported in SolrCloud mode. As an alternative, in order to upgrade index, configure LatestVersionMergePolicyFactory in solrconfig.xml and reindex the data in your collection.");
}

SolrParams params = it.req.getParams();
String cname = params.required().get(CoreAdminParams.CORE);
final boolean isAsync = params.get(CommonAdminParams.ASYNC) != null;
final var requestBody = new UpgradeCoreIndexRequestBody();
requestBody.updateChain = params.get(UpdateParams.UPDATE_CHAIN);

UpgradeCoreIndex upgradeCoreIndexApi =
UPGRADE_CORE_INDEX_FACTORY.create(
it.handler.coreContainer, it.handler.coreAdminAsyncTracker, it.req, it.rsp);
final UpgradeCoreIndexResponse response =
upgradeCoreIndexApi.upgradeCoreIndex(cname, requestBody);
V2ApiUtils.squashIntoSolrResponseWithoutHeader(it.rsp, response);

if (isAsync) {
final var opResponse = new NamedList<>();
V2ApiUtils.squashIntoNamedListWithoutHeader(opResponse, response);
// REQUESTSTATUS is returning the inner response NamedList as a positional array
// ([k1,v1,k2,v2...]).
// so converting to a map
it.rsp.addResponse(opResponse.asMap(1));
}
}
}
Loading