Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing Test: Lucene.Net.Index.TestIndexWriter::TestTwoThreadsInterruptDeadlock() #544

Closed
NightOwl888 opened this issue Nov 18, 2021 · 0 comments · Fixed by #555
Closed
Labels
help-wanted Extra attention is needed is:bug pri:high test-failure up-for-grabs This issue is open to be worked on by anyone
Milestone

Comments

@NightOwl888
Copy link
Contributor

NightOwl888 commented Nov 18, 2021

For information about how to help us debug tests, see #269.

This test was previously reported as failing in #269. However, the behavior is slightly different now after the patch was applied in #525.

This test only started failing again after fixing the test framework to randomize the codecs, culture and time zone (NUnit's Randomizer was always initialized with a seed of 0, so none of these were actually random).

Lucene.Net.Util.LuceneSystemException : MockDirectoryWrapper: cannot close: there are still open locks: [write.lock]
Data:
OriginalMessage: Lucene.Net.Util.LuceneSystemException: MockDirectoryWrapper: cannot close: there are still open locks: [write.lock]
at Lucene.Net.Store.MockDirectoryWrapper.Dispose(Boolean disposing) in D:\a\1\s\src\Lucene.Net.TestFramework\Store\MockDirectoryWrapper.cs:line 1096
at Lucene.Net.Store.Directory.Dispose() in D:\a\1\s\src\Lucene.Net\Store\Directory.cs:line 134
at Lucene.Net.Util.IOUtils.ReThrowUnchecked(Exception th) in D:\a\1\s\src\Lucene.Net\Util\IOUtils.cs:line 530
at Lucene.Net.Index.TestIndexWriter.IndexerThreadInterrupt.Run() in D:\a\1\s\src\Lucene.Net.Tests\Index\TestIndexWriter.cs:line 1434
at J2N.Threading.ThreadJob.SafeRun(ThreadStart start)

To reproduce this test result:

Option 1:

Apply the following assembly-level attributes:

[assembly: Lucene.Net.Util.RandomSeed(0x988353ef90a15617L)]
[assembly: NUnit.Framework.SetCulture("fr-CA")]

Option 2:

Use the following .runsettings file:

<RunSettings>
  <TestRunParameters>
    <Parameter name="tests:seed" value="0x988353ef90a15617" />
    <Parameter name="tests:culture" value="fr-CA" />
  </TestRunParameters>
</RunSettings>

See the .runsettings documentation at: https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file.
at Lucene.Net.Store.MockDirectoryWrapper.Dispose(Boolean disposing) in D:\a\1\s\src\Lucene.Net.TestFramework\Store\MockDirectoryWrapper.cs:line 1096
at Lucene.Net.Store.Directory.Dispose() in D:\a\1\s\src\Lucene.Net\Store\Directory.cs:line 134
at Lucene.Net.Util.IOUtils.ReThrowUnchecked(Exception th) in D:\a\1\s\src\Lucene.Net\Util\IOUtils.cs:line 530
at Lucene.Net.Index.TestIndexWriter.IndexerThreadInterrupt.Run() in D:\a\1\s\src\Lucene.Net.Tests\Index\TestIndexWriter.cs:line 1434
at J2N.Threading.ThreadJob.SafeRun(ThreadStart start)
--- End of stack trace from previous location ---
at Lucene.Net.Index.TestIndexWriter.TestTwoThreadsInterruptDeadlock() in D:\a\1\s\src\Lucene.Net.Tests\Index\TestIndexWriter.cs:line 1556

The test is not repeatable with the random seed, which likely indicates we have an actual concurrency issue this time. We also do not see Lucene.Net.Index.TestIndexWriter.TestThreadInterruptDeadlock() fail anymore, which indicates likewise.

NOTE: I am working on a PR to fix the random seed functionality #288 now, and the settings in the error message don't exist in master yet.

It is failing on every target except .NET Framework, every OS and both in x86 and x64, but rarely (less than 1 run out of 20).

@NightOwl888 NightOwl888 added up-for-grabs This issue is open to be worked on by anyone help-wanted Extra attention is needed is:bug test-failure pri:high labels Nov 18, 2021
@NightOwl888 NightOwl888 changed the title Failing Test: Lucene.Net.Index.TestIndexWriter.TestTwoThreadsInterruptDeadlock() Failing Test: Lucene.Net.Index.TestIndexWriter::TestTwoThreadsInterruptDeadlock() Nov 18, 2021
@NightOwl888 NightOwl888 added this to the 4.8.0 milestone Nov 18, 2021
NightOwl888 added a commit to NightOwl888/lucenenet that referenced this issue Nov 22, 2021
…d [AwaitsFix] attribute, as this is sometimes failing (see apache#544)
NightOwl888 added a commit that referenced this issue Nov 22, 2021
…peatable (Fixes #288) (#547)

* Lucene.Net.TestFramework.Util.LuceneTestCase: Added message to the test result on how to set a fixed random seed to reproduce the test result (pass or fail).

* Lucene.Net.TestFramework.Util: Added customized TestFixtureAttribute, and NUnitTestFixtureBuilder along with RandomSeedAttribute and LuceneRandomSeedInitializer to fix the broken randomized seed functionality so we can repeat test runs reliably.

* BREAKING: Lucene.Net.Util.StringHelper.GOOD_FAST_HASH_SEED: converted from a static field to a property and marked obsolete. Added a new property GoodFastHashSeed. Removed SystemProperties call to populate the value of the field, since NUnit only allows us to generate a seed per test, and we need a way to inject the seed value for repeatability.

* Lucene.Net.TestFramework.Support.Util.LuceneRandomSeedInitializer: Added line to set StringHelper.goodFastHashSeed when the test framework is attached.

* Lucene.Net.TestFramework.Util.LuceneTestCase: Stow Random instance in test properties if we are in a suite context

* Lucene.Net.TestFramework: Reworked LuceneRandomSeedIntiailizer and changed RandomSeedAttribute to be an assembly-level attribute

* Lucene.Net.TestFramework: Removed support for Randomizer.InitialSeed and store the seed in a property of the test fixture (instance-based rather than static)

* Lucene.Net.Tests.TestFramework.Support.TestApiConsistency: Added exclusion for RandomSeed constant

* Lucene.Net.TestFramework.Util.TestRuleSetupAndRestoreClassEnv: Changed system property to prefer "tests:culture" instead of "tests:locale" to set the culture, but left "tests:locale" in for backward/java compatibility.

* Lucene.Net.TestFramework: Created RandomizedContext class to store as an NUnit test property for each test. This allows us to add additional strongly-typed properties to the test without wrapping the class. Changed to use J2N.Randomizer and changed all seeds to long rather than int. Converted the number for setting the random seed to hexadecimal and updated the message to add the setting for the current culture to the attributes/.runsettings file.

* BREAKING: Added LuceneSetUpFixtureBuilder class to load either a subclass or our default instance of LuceneTestFrameworkInitializer. Also added LuceneTestCase.SetUpFixture to control initialization of LuceneTestFrameworkInitializer so it is only called on setup and teardown for the assembly. Added Initialize() method to LuceneTestFrameworkInitializer that must be used to set the factories.

* Lucene.Net.TestFramework.Util.LuceneTestCase: Only print out the detailed random repeat message on failure or error

* BREAKING: Lucene.Net.TestFramework.Util.LuceneTestCase: Deprecated GetClassType() method and added TestType property

* BREAKING: Lucene.Net.TestFramework.Util.AbstractBeforeAfterRule: Removed LuceneTestCase parameter from Before() and After() methods.

* Lucene.Net.Util.LuceneRandomSeedInitializer: Added overload of InitializeTestFixture that accepts RandomizedContext so NUnitTestFixtureBuilder doesn't have to deal with setting NUnit properties. Also added RandomizedContext.CurrentTestAssembly property.

* Lucene.Net.TestFramework.Util: Added UseTempLineDocsFileAttribute and a UseTempLineDocFileRule to scan for it and execute the file decompression and cleanup. Removed the unnecessary Startup.cs files that only served the purpose of getting NUnit to recognize LuceneTestFrameworkInitializer in the assembly scan.

* Lucene.Net.TestFramework.Util.TestRuleSetupAndRestoreClassEnv: Allow NUnit's [SetCulture] attribute to be used to set the culture

* Lucene.Net.TestFramework.Util.LuceneTestCase: Updated repeat instructions to use NUnit's SetCulture attribute, since NUnit property attributes are not currently read by the test framework

* Lucene.Net.TestFramework.Analysis.BaseTokenStreamTestCase: Switched from using System.Random to J2N.Randomizer

* Lucene.Net.Tests.Analysis.Common.Analysis.Core.TestRandomChains: Switched from using System.Random to J2N.Randomizer. Also added feature to export a random SynonymMap as source code.

* azure-pipelines.yml: set maximumAllowedFailures to 0

* SWEEP: Marked all of the latest test failures with [AwaitsFix] attribute and an issue URL.

* Lucene.Net.Classification.KNearestNeighborClassifierTest::TestPerformance(): Ignore in net461, since it runs a bit slow in that environment.

* Lucene.Net.Index.TestIndexWriter::TestThreadInterruptDeadlock(): Added [AwaitsFix] attribute, as this is sometimes failing (see #544)

* Lucene.Net.Tests.Join.TestJoinUtil::TestMultiValueRandomJoin(): Added [AwaitsFix] attribute, since this test is failing on .NET Framework x86 in Release mode.

* SWEEP: Changed all test instances of System.Random to J2N.Randomizer. APIs remain as System.Random, since J2N.Randomizer is a subclass.

* Lucene.Net.TestFramework.Util.MethodInfoComparer: Made into singleton

* Lucene.Net.Classification.KNearestNeighborClassifierTest::TestPerformance(): Adjusted limit from 2 min to 2.5 min for .NET Framework, since it runs a bit slow in CI.
NightOwl888 added a commit to NightOwl888/lucenenet that referenced this issue Nov 23, 2021
…interruptableMonitor: Ignore tests that call Thread.Interrupt(), as this is not supportable in .NET. Closes apache#544.
NightOwl888 added a commit that referenced this issue Nov 23, 2021
…interruptableMonitor: Ignore tests that call Thread.Interrupt(), as this is not supportable in .NET. Closes #544.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Extra attention is needed is:bug pri:high test-failure up-for-grabs This issue is open to be worked on by anyone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant