mpetris commented on code in PR #1155:
URL: https://github.com/apache/solr/pull/1155#discussion_r1044557278
##########
solr/core/src/java/org/apache/solr/core/SolrCores.java:
##########
@@ -555,23 +658,41 @@ public boolean isCoreLoading(String name) {
}
public void queueCoreToClose(SolrCore coreToClose) {
- synchronized (modifyLock) {
+ READ_WRITE_LOCK.writeLock().lock();
+ try {
pendingCloses.add(coreToClose); // Essentially just queue this core up
for closing.
- modifyLock.notifyAll(); // Wakes up closer thread too
+ WRITE_LOCK_CONDITION.signalAll(); // Wakes up closer thread too
+ } finally {
+ READ_WRITE_LOCK.writeLock().unlock();
}
}
/**
* @return the cache holding the transient cores; never null.
*/
public TransientSolrCoreCache getTransientCacheHandler() {
- synchronized (modifyLock) {
- if (transientSolrCoreCacheFactory == null) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR,
- getClass().getName() + " not loaded; call load() before using it");
- }
- return transientSolrCoreCacheFactory.getTransientSolrCoreCache();
+ READ_WRITE_LOCK.writeLock().lock();
+ try {
+ return getInternalTransientCacheHandler();
+ } finally {
+ READ_WRITE_LOCK.writeLock().unlock();
+ }
+ }
+
+ /**
+ * Explicitly does not use a lock to provide the flexibility to choose
between a read-lock and a
+ * write-lock before calling this method. Choosing a lock and locking before
calling this method
+ * is mandatory. Note: Using always a write-lock would be costly. Using
always a read-lock would
+ * block all calls which already hold a write-lock.
+ *
+ * @return the cache holding the transient cores; never null.
+ */
+ private TransientSolrCoreCache getInternalTransientCacheHandler() {
Review Comment:
OK, but getTransientCacheWithLock as a name for the private
`getInternalTransientCacheHandler` sounds to me as if the method aquired the
lock on its own. How about getTransientCacheHandlerNonLocked()?
--
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]