Rolling Upgrades Using JavaScript or XQuery
- Last Updated: April 15, 2026
- 2 minute read
- MarkLogic Server
- Version 12.0
- Documentation
The Admin APIs can be used to set up and perform a rolling upgrade through the Query Console. This section contains sample code that you can use from the Query Console.
To get the host versions through REST, use one of these code options:
JavaScript
var hostNames = []
for (var hostName of xdmp.hosts()) {
hostNames.push(xdmp.hostName(hostName))
}
var hosts = [];
for (var hostName of hostNames) {
var url = "http://localhost:8002/manage/v2/hosts/" + hostName + "?view=status&format=json"
var response = xdmp.httpGet(url, {
authentication: {
method: "digest",
username: "admin",
password: "admin"
},
headers: {
"content-type": "application/json"
}
});
var responseData = response.toObject()[1].root;
hosts.push({
name: responseData.xpath('//*:name/string()'),
"host-software-version": responseData.xpath('//*:software-version/value/data()'),
"cluster-effective-version": responseData.xpath('//*:effective-version/value/data()')
});
}
var result = "<hosts>";
for (var j = 0; j < hosts.length; j++) {
result += "<host>";
result += "<name>" + hosts[j].name + "</name>";
result += "<host-software-version>" + hosts[j]["host-software-version"] + "</host-software-version>";
result += "<cluster-effective-version>" + hosts[j]["cluster-effective-version"] + "</cluster-effective-version>";
result += "</host>";
}
result += "</hosts>";
result
XQuery
xquery version "1.0-ml";
<hosts>{
for $i in xdmp:host-name(xdmp:hosts())
return (
let $response := xdmp:http-get(concat("http://localhost:8002/manage/v2/hosts/",$i,"?view=status&format=json"),
<options xmlns="xdmp:http">
<authentication method="digest">
<username>admin</username>
<password>admin</password>
</authentication>
<headers>
<content-type>application/json</content-type>
</headers>
</options>)
return (
<host>
<name>{$response[2]//*:name/data()}</name>
<host-software-version>{$response[2]//*:software-version/value/data()}</host-software-version>
<cluster-effective-version>{$response[2]//*:effective-version/value/data()}</cluster-effective-version>
</host>
)
)
}</hosts>
To complete the upgrade, log in to the Admin Interface to upgrade the Security database.
Note:
Committing the upgrade results in the updated configuration being saved with a re-read delay of 5 seconds to ensure that all online hosts have received the new file before XDQP connections start dropping.
See Step 7 in Upgrading an EC2 Instance. If the servers do not have the correct version, then there may be a host that is in maintenance mode. The admin.canCommitUpgrade() or admin:can-commit-upgrade() function returns true if all servers have the correct software version. See Admin APIs for more about the Admin APIs available.