serhiy-bzhezytskyy commented on PR #4784:
URL: https://github.com/apache/solr/pull/4784#issuecomment-5392083977

   Dug into why Lucene deprecated the check-then-act lock pattern: 
LUCENE-6507/6508 removed it because closing a throwaway probe lock can 
invalidate a different, real lock under some native lock implementations. 
OpenSearch follows that -- `InternalEngine.createWriter()` never pre-checks, it 
just attempts the real `IndexWriter` and catches `LockObtainFailedException` 
from that attempt.
   
   Solr can't drop the check the same way OpenSearch does -- 
`DefaultSolrCoreState` creates its writer lazily on first write, so removing 
the probe outright would mean a locked index no longer fails core load (there's 
an explicit test for this, `SolrCoreCheckLockOnStartupTest`).
   
   But `solrCoreState` is already constructed before `initIndex()` runs. So 
instead of a throwaway probe, this now eagerly calls 
`solrCoreState.getIndexWriter(this, false)` -- the real, cached writer, created 
once, no separate probe. A lock conflict fails core load the same way, through 
`LockObtainFailedException` (which `SolrIndexWriter.create()` now wraps with 
the same descriptive message). Net diff is smaller than before (-25 lines), no 
constructor reordering needed. Verified against 
`SolrCoreCheckLockOnStartupTest` (both lock types) plus 6 other test classes 
including a distributed one.
   
   AI-assisted (Claude Sonnet 5)


-- 
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]

Reply via email to