Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions changelog/unreleased/SOLR-17704-curator-locks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
title: Collection and ConfigSet API locks without the Overseer now use Apache Curator; upgrading such clusters needs a full restart or paused API commands
type: changed
authors:
- name: Amrit Sarkar
links:
- name: SOLR-17704
url: https://issues.apache.org/jira/browse/SOLR-17704
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ apache-commons-math3 = { module = "org.apache.commons:commons-math3", version.re
apache-commons-text = { module = "org.apache.commons:commons-text", version.ref = "apache-commons-text" }
apache-curator-client = { module = "org.apache.curator:curator-client", version.ref = "apache-curator" }
apache-curator-framework = { module = "org.apache.curator:curator-framework", version.ref = "apache-curator" }
apache-curator-recipes = { module = "org.apache.curator:curator-recipes", version.ref = "apache-curator" }
apache-curator-test = { module = "org.apache.curator:curator-test", version.ref = "apache-curator" }
apache-httpcomponents-httpclient = { module = "org.apache.httpcomponents:httpclient", version.ref = "apache-httpcomponents-httpclient" }
apache-httpcomponents-httpcore = { module = "org.apache.httpcomponents:httpcore", version.ref = "apache-httpcomponents-httpcore" }
Expand Down
1 change: 1 addition & 0 deletions solr/api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ org.apache.commons:commons-lang3:3.20.0=jarValidation,swaggerBuild,testRuntimeCl
org.apache.commons:commons-math3:3.6.1=jarValidation,testRuntimeClasspath
org.apache.curator:curator-client:5.9.0=jarValidation,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-framework:5.9.0=jarValidation,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-recipes:5.9.0=jarValidation,testRuntimeClasspath
org.apache.curator:curator-test:5.9.0=jarValidation,testRuntimeClasspath
org.apache.logging.log4j:log4j-api:2.26.1=jarValidation,testRuntimeClasspath
org.apache.logging.log4j:log4j-core:2.26.1=jarValidation,testRuntimeClasspath
Expand Down
1 change: 1 addition & 0 deletions solr/benchmark/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ org.apache.commons:commons-lang3:3.20.0=jarValidation,runtimeClasspath,testRunti
org.apache.commons:commons-math3:3.6.1=annotationProcessor,compileClasspath,jarValidation,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-client:5.9.0=compileClasspath,jarValidation,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-framework:5.9.0=compileClasspath,jarValidation,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-recipes:5.9.0=jarValidation,runtimeClasspath,testRuntimeClasspath
org.apache.curator:curator-test:5.9.0=jarValidation,runtimeClasspath,testRuntimeClasspath
org.apache.logging.log4j:log4j-api:2.26.1=jarValidation,runtimeClasspath,testRuntimeClasspath
org.apache.logging.log4j:log4j-core:2.26.1=jarValidation,runtimeClasspath,testRuntimeClasspath
Expand Down
3 changes: 3 additions & 0 deletions solr/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ dependencies {
implementation(libs.apache.curator.framework, {
exclude group: 'org.apache.zookeeper', module: 'zookeeper'
})
implementation(libs.apache.curator.recipes, {
exclude group: 'org.apache.zookeeper', module: 'zookeeper'
})
implementation(libs.apache.curator.client, {
exclude group: 'org.apache.zookeeper', module: 'zookeeper'
})
Expand Down
1 change: 1 addition & 0 deletions solr/core/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ org.apache.commons:commons-lang3:3.20.0=cliDocsRuntime,compileClasspath,jarValid
org.apache.commons:commons-math3:3.6.1=cliDocsRuntime,compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-client:5.9.0=cliDocsRuntime,compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-framework:5.9.0=cliDocsRuntime,compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-recipes:5.9.0=cliDocsRuntime,compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
org.apache.curator:curator-test:5.9.0=jarValidation,testCompileClasspath,testRuntimeClasspath
org.apache.logging.log4j:log4j-api:2.26.1=cliDocsRuntime,compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
org.apache.logging.log4j:log4j-core:2.26.1=cliDocsRuntime,compileClasspath,jarValidation,runtimeClasspath,runtimeLibs,testCompileClasspath,testRuntimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public ConfigSetApiLockFactory(DistributedConfigSetLockFactory lockFactory) {
* <p>This method obtains a write lock on {@code configSetName} as well as (when not {@code
* null}), a read lock on {@code baseConfigSetName}.
*
* @return a lock that once {@link DistributedMultiLock#isAcquired()} guarantees the corresponding
* Config Set API command can execute safely. The returned lock <b>MUST</b> be {@link
* DistributedMultiLock#release()} no matter what once no longer needed as otherwise it would
* prevent other threads from locking.
* @return a lock that once {@link DistributedMultiLock#waitUntilAcquired()} returns guarantees
* the corresponding Config Set API command can execute safely. The returned lock <b>MUST</b>
* be {@link DistributedMultiLock#release()} no matter what once no longer needed as otherwise
* it would prevent other threads from locking.
*/
public DistributedMultiLock createConfigSetApiLock(
String configSetName, String baseConfigSetName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@

public interface DistributedCollectionLockFactory {
/**
* Create a new lock of the specified type (read or write) entering the "competition" for actually
* getting the lock at the given level for the given path i.e. a lock at {@code collName} or a
* lock at {@code collName/shardId} or a lock at {@code collName/shardId/replicaName}, depending
* on the passed {@code level}.
* Create a new lock of the specified type (read or write) at the given level for the given path
* i.e. a lock at {@code collName} or a lock at {@code collName/shardId} or a lock at {@code
* collName/shardId/replicaName}, depending on the passed {@code level}.
*
* <p>The paths are used to define which locks compete with each other (locks of equal paths
* compete).
*
* <p>Upon return from this call, the lock <b>has not been acquired</b> but the it had entered the
* lock acquiring "competition", and the caller can decide to wait until the lock is granted by
* calling {@link DistributedLock#waitUntilAcquired()}.<br>
* <p>Upon return, the lock <b>has not been acquired</b>. It enters the competition in {@link
* DistributedLock#waitUntilAcquired()}.<br>
* Separating the lock creation from lock acquisition allows a more deterministic release of the
* locks when/if they can't be acquired.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@

public interface DistributedConfigSetLockFactory {
/**
* Create a new lock of the specified type (read or write) entering the "competition" for actually
* getting the lock for the {@code configSetName}
* Create a new lock of the specified type (read or write) for the {@code configSetName}
*
* <p>Upon return from this call, the lock <b>has not been acquired</b> but the it had entered the
* lock acquiring "competition", and the caller can decide to wait until the lock is granted by
* calling {@link DistributedLock#waitUntilAcquired()}.<br>
* <p>Upon return, the lock <b>has not been acquired</b>. It enters the competition in {@link
* DistributedLock#waitUntilAcquired()}.<br>
* Separating the lock creation from lock acquisition allows a more deterministic release of the
* locks when/if they can't be acquired.
*
Expand Down
7 changes: 4 additions & 3 deletions solr/core/src/java/org/apache/solr/cloud/DistributedLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@

package org.apache.solr.cloud;

/** A lock that can be used across cluster nodes. */
/**
* A lock that can be used across cluster nodes. {@link #waitUntilAcquired()} and {@link #release()}
* must be called on the same thread.
*/
public interface DistributedLock {
void waitUntilAcquired();

void release();

boolean isAcquired();

String getLockId();

boolean isMirroringLock();
Expand Down
25 changes: 12 additions & 13 deletions solr/core/src/java/org/apache/solr/cloud/DistributedMultiLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,21 @@ public void waitUntilAcquired() {

public void release() {
isReleased = true;
RuntimeException failure = null;
for (DistributedLock lock : locks) {
lock.release();
}
}

public boolean isAcquired() {
if (isReleased) {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR, "Released lock can't be tested");
}
for (DistributedLock lock : locks) {
if (!lock.isAcquired()) {
return false;
try {
lock.release();
} catch (RuntimeException e) {
if (failure == null) {
failure = e;
} else {
failure.addSuppressed(e);
}
}
}
return true;
if (failure != null) {
throw failure;
}
}

public String getLockId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
public class ZkDistributedCollectionLockFactory extends ZkDistributedLockFactory
implements DistributedCollectionLockFactory {

public ZkDistributedCollectionLockFactory(SolrZkClient zkClient, String rootPath) {
super(zkClient, rootPath);
public ZkDistributedCollectionLockFactory(
SolrZkClient zkClient, String rootPath, String nodeName) {
super(zkClient, rootPath, nodeName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
public class ZkDistributedConfigSetLockFactory extends ZkDistributedLockFactory
implements DistributedConfigSetLockFactory {

public ZkDistributedConfigSetLockFactory(SolrZkClient zkClient, String rootPath) {
super(zkClient, rootPath);
public ZkDistributedConfigSetLockFactory(
SolrZkClient zkClient, String rootPath, String nodeName) {
super(zkClient, rootPath, nodeName);
}

@Override
Expand Down
Loading