Skip to content

[fix](fe) Prevent port conflicts during mocked FE startup - #70526

Open
shuke987 wants to merge 2 commits into
apache:masterfrom
shuke987:codex/feut-hold-rpc-listener
Open

shuke987 wants to merge 2 commits into
apache:masterfrom
shuke987:codex/feut-hold-rpc-listener

Conversation

@shuke987

@shuke987 shuke987 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Background

FE unit tests start a mocked frontend in each test JVM. It uses a local file journal and disables the query and HTTP services. Mock backends still need to call the FE's advertised Thrift RPC port.

What problem does this PR solve?

Issue Number: None
Related PR: None
PR Type: Bugfix

Mocked FE startup could exit the entire test JVM when another process occupied a port between selection and startup. The FE now keeps the ephemeral RPC listener bound until Thrift takes ownership. Startup checks the other ports only for the selected journal and enabled services.

Details

  • In one parallel run, Thrift could not bind the previously selected RPC port. Other runs failed earlier in DorisFE.checkAllPorts: AnotherDemoTest reported an occupied edit-log port and RestoreCommandTest an occupied query port. Both forks exited with code 255 before writing their JUnit XML.
  • The mocked FE binds an ephemeral RPC listener before catalog initialization and advertises its assigned port to the backends. The blocking Thrift server accepts that socket. Providers that need their own transport retain the port-based startup path.
  • Port preflight checks the replication port for a BDB journal, the query and Arrow Flight SQL ports for an enabled query service, and HTTP(S) ports for an enabled HTTP server. A local file journal opens no replication listener.

Testing

  • Held the edit-log and query ports open throughout a startup preflight test. The previous implementation failed with the local journal and query service disabled. The updated preflight passes in that mode and rejects the occupied port when BDB or the query service is enabled.
  • Ran AnotherDemoTest, RestoreCommandTest, and DemoTest.testAdvertisedRpcPort concurrently in three local JVMs. All four test methods passed. The RPC test connects to the port advertised to the mock backend.
  • A separate three-fork Maven run reproduced a shared plugin-directory creation failure in RestoreCommandTest (PluginMgr.init, before the test wrote its XML). Its mocked FE log identified a filesystem error. The other four selected classes completed.
  • The repository’s run-fe-ut.sh selected five test classes with one fork. All six selected methods passed with zero skips, failures or errors.
  • The earlier RPC verification passed all 12 tests in ThriftServerTest and CheckRowPolicyTest. FE Core Checkstyle passed for the updated code and test.

Release note

None

Check List (For Author)

  • Behavior changed: Yes. Port preflight follows the configured journal and enabled services.
  • Does this need documentation: No.
  • Pre-submission status: Ready.

AI Disclosure

  • Tool: OpenAI Codex (GPT-6).
  • Generated: Code changes, regression tests, local validation and PR description.
  • Human review: Pending.

### What problem does this PR solve?

Issue Number: None
Related PR: None

Parallel FE unit tests could lose a probed RPC port before Thrift started,
causing FE startup to exit the test JVM. Bind an ephemeral listener once,
publish the assigned port before catalog initialization, and pass the live
listener to the blocking Thrift server.

### Release note

None

### Check List (For Author)

- Test: ThriftServerTest and CheckRowPolicyTest passed (12 tests). FE Checkstyle passed.
- Behavior changed: No user-facing change.
- Does this need documentation: No.
@shuke987

Copy link
Copy Markdown
Contributor Author

run buildall

@shuke987

Copy link
Copy Markdown
Contributor Author

run feut

### Background

Mocked FE tests use a local journal and disable the query and HTTP services.
Startup still tried binding their configured ports before starting the catalog.

### What problem does this PR solve?

Issue Number: None
Related PR: None
PR Type: Bugfix

AnotherDemoTest exited when the edit-log port was occupied. RestoreCommandTest
exited at the same startup check for the query port. Use the configured journal
and startup options to select listener checks. Enabled services still detect
port conflicts before startup.

### Testing

Held the edit-log and query sockets open during preflight. The previous
implementation failed for a local journal and disabled query service. The new
implementation passes and rejects the occupied port when BDB or the query
service is enabled. Ran AnotherDemoTest, RestoreCommandTest and the RPC callback
test concurrently in separate local JVMs. FE Core Checkstyle passed.

### Release note

None

### Check List (For Author)

- Behavior changed: Yes. Port preflight follows the selected journal and services.
- Does this need documentation: No.
- Pre-submission status: Ready.

### AI Disclosure

- Tool: OpenAI Codex.
- Generated: Code, regression test and validation.
@shuke987 shuke987 changed the title [fix](fe) Keep the mocked FE RPC listener bound through startup [fix](fe) Prevent port conflicts during mocked FE startup Nov 13, 2026
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.

1 participant