Skip to content

SOLR-18294: Fix flaky IndexFetcherPacketProtocolTest#4624

Open
shubhamranjan wants to merge 12 commits into
apache:mainfrom
shubhamranjan:main
Open

SOLR-18294: Fix flaky IndexFetcherPacketProtocolTest#4624
shubhamranjan wants to merge 12 commits into
apache:mainfrom
shubhamranjan:main

Conversation

@shubhamranjan

Copy link
Copy Markdown
Contributor

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

Description

IndexFetcherPacketProtocolTest fails intermittently (~5%) with:

java.lang.AssertionError: fetchPackets return code mismatch expected:<0> but was:<1>

The test writes its sample file into the core index directory obtained with DirContext.DEFAULT, then has the sender (ReplicationAPIBase.DirectoryFileStream) serialize it. The sender reads via DirContext.REPLICATION, which CachingDirectoryFactory.filterDirectory() resolves through FilterDirectory.unwrap() to the raw delegate. Under the randomized test DirectoryFactory, a file written through the wrapped (DEFAULT) view can be invisible through the unwrapped (REPLICATION) view, so the sender throws NoSuchFileException, emits an empty stream, and the receiver returns NO_CONTENT (1) — failing the assertion.

Solution

Acquire the directory in the test with the same REPLICATION DirContext the sender uses, so the write and the read target the same delegate Directory. Test-only change; production replication is unaffected (it serves committed, fsync'd segments that are always present on the delegate).

Tests

  • IndexFetcherPacketProtocolTest passes.
  • Beasted, including -Ptests.nightly=true and -Ptests.directory=ByteBuffersDirectory, with no failures.

Checklist

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.

The test wrote its sample file into the core index directory acquired
with DirContext.DEFAULT, while the sender (DirectoryFileStream) reads it
with DirContext.REPLICATION. CachingDirectoryFactory.filterDirectory()
unwraps REPLICATION/BACKUP directories via FilterDirectory.unwrap() to
the raw delegate, so under the randomized test DirectoryFactory the file
written through the wrapped view could be invisible through the
unwrapped view, intermittently throwing NoSuchFileException -> empty
stream -> NO_CONTENT and failing the round-trip assertion.

Acquire the directory with the same REPLICATION DirContext the sender
uses, so the write and the read target the same delegate.
@github-actions github-actions Bot added the tests label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant