Skip to content

SOLR-18364: Remove deprecated SolrCore.isWriterLocked(Directory) - #4784

Open
serhiy-bzhezytskyy wants to merge 1 commit into
apache:mainfrom
serhiy-bzhezytskyy:SOLR-18364-remove-iswriterlocked
Open

SOLR-18364: Remove deprecated SolrCore.isWriterLocked(Directory)#4784
serhiy-bzhezytskyy wants to merge 1 commit into
apache:mainfrom
serhiy-bzhezytskyy:SOLR-18364-remove-iswriterlocked

Conversation

@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-18364

isWriterLocked(Directory) has been @Deprecated(since = "7.0") since Robert Muir's 2016 removal of Lucene's own IndexWriter.isLocked(), with its own javadoc noting "use of this method can only lead to race conditions." It's private with a single internal call site, in SolrCore.initIndex().

Removed the wrapper and inlined its check-then-release body directly at that one call site — same behavior, one less indirection:

boolean writerLocked;
try {
  dir.obtainLock(IndexWriter.WRITE_LOCK_NAME).close();
  writerLocked = false;
} catch (LockObtainFailedException failed) {
  writerLocked = true;
}
if (writerLocked) {
  ...
}

No changelog entry — internal/private method, nothing externally visible changes.

Tests: SolrCoreCheckLockOnStartupTest (exercises this exact path) green.

AI-assisted (Claude Sonnet 5)

Internal, private, single call site. Inlined its check-then-release
logic directly into initIndex() and removed the wrapper method.
final String lockType = getSolrConfig().indexConfig.lockType;
Directory dir = directoryFactory.get(indexDir, DirContext.DEFAULT, lockType);
try {
if (isWriterLocked(dir)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite seeing how this is different? I think this just inlines the isWriterLocked method? I guess I'm looking for some different method on dir.objectLock?

@epugh

epugh commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

I think we need to figure out hwo to duplicate this logic in modern Lucene...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants