SteNicholas commented on code in PR #501:
URL: https://github.com/apache/paimon-cpp/pull/501#discussion_r4452772840


##########
src/paimon/global_index/lucene/lucene_directory.cpp:
##########
@@ -40,7 +40,7 @@ LuceneDirectory::LuceneDirectory(
       path_(path),
       file_name_to_offset_and_length_(file_name_to_offset_and_length),
       paimon_input_(paimon_input) {
-    
Lucene::Directory::setLockFactory(Lucene::NoLockFactory::getNoLockFactory());
+    
Lucene::Directory::setLockFactory(Lucene::newLucene<Lucene::NoLockFactory>());

Review Comment:
   Could we add a short comment here, and at the writer-side allocation, 
explaining why each directory needs its own `NoLockFactory`? 
`Directory::setLockFactory()` mutates the factory's `lockPrefix`, so sharing 
the singleton across directories introduces a data race. This is worth keeping 
next to the code because Lucene++'s own class documentation recommends 
`getNoLockFactory()`, which could otherwise lead a future cleanup to 
reintroduce the issue.



##########
src/paimon/global_index/lucene/lucene_directory_test.cpp:
##########
@@ -32,6 +39,42 @@ class LuceneDirectoryTest : public ::testing::Test, public 
::testing::WithParamI
     void TearDown() override {}
 };
 

Review Comment:
   Could we also add a concurrent creation regression test through 
`LuceneGlobalIndexWriter::Create()`? This test only constructs 
`LuceneDirectory`, so reverting the writer-side change would leave it passing 
while concurrent writers could still mutate the singleton factory's 
`lockPrefix`. Exercising multiple writer creations under TSAN would cover the 
other production path changed by this fix.



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

Reply via email to