Skip to content

[Bug][Zeta] SeaTunnelClient can not exit with error #9281

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

Merged
merged 19 commits into from
May 17, 2025

Conversation

CosmosNi
Copy link
Contributor

@CosmosNi CosmosNi commented May 7, 2025

SeaTunnelClient can not exit with error

close #9257

Purpose of this pull request

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

@github-actions github-actions bot added core SeaTunnel core module Zeta labels May 7, 2025
@hailin0 hailin0 requested a review from Copilot May 7, 2025 01:50
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request fixes a bug where SeaTunnel components do not exit with an error by adding explicit error handling with System.exit(1) on fatal errors during Hazelcast initialization. Key changes include modifications in the server starter, Hazelcast client, and client command components to catch Errors and call System.exit(1).

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

File Description
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServerStarter.java Added try-catch block around Hazelcast initialization to log and exit on fatal errors.
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/SeaTunnelHazelcastClient.java Updated the constructor to catch Errors during client initialization and exit with an error code.
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ClientExecuteCommand.java Wrapped Hazelcast instance creation in a try-catch block to handle fatal errors and exit properly.
Files not reviewed (1)
  • pom.xml: Language not supported

} catch (Error e) {
log.error("Fatal error occurred during Hazelcast server initialization", e);
System.exit(1);
throw e;
Copy link
Preview

Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] After calling System.exit(1), rethrowing the error is redundant since the JVM will terminate. Consider removing the rethrow for clarity unless it is required for testing purposes.

Suggested change
throw e;

Copilot uses AI. Check for mistakes.

} catch (Error e) {
log.error("Fatal error occurred during Hazelcast client initialization", e);
System.exit(1);
throw e;
Copy link
Preview

Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The rethrow after System.exit(1) is generally unnecessary since the process will terminate. Consider removing or documenting this pattern if it serves a specific testing purpose.

Suggested change
throw e;

Copilot uses AI. Check for mistakes.

} catch (Error e) {
log.error("Fatal error occurred during Hazelcast instance initialization", e);
System.exit(1);
throw e;
Copy link
Preview

Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Rethrowing the exception after calling System.exit(1) is redundant. Consider removing the rethrow to avoid unreachable code or adding a clarifying comment if needed for testing.

Suggested change
throw e;
// Note: The following line is unreachable due to System.exit(1).
// Uncomment for testing purposes if System.exit is mocked.
// throw e;

Copilot uses AI. Check for mistakes.

Comment on lines 285 to 288
return HazelcastInstanceFactory.newHazelcastInstance(
seaTunnelConfig.getHazelcastConfig(),
Thread.currentThread().getName(),
new SeaTunnelNodeContext(seaTunnelConfig));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create hazelcast instance is one of potential crisis. So we should handle it in

to catch all exist problem.

@github-actions github-actions bot removed the Zeta label May 7, 2025
@Hisoka-X
Copy link
Member

Hisoka-X commented May 7, 2025

wating test case passes.

@Hisoka-X
Copy link
Member

Hisoka-X commented May 9, 2025

Hi @CosmosNi , please merge from dev to disable dead link check.

Comment on lines 42 to 47
showConfigError(e);
System.exit(1);
throw e;
} catch (Exception e) {
} catch (Exception | Error e) {
showFatalError(e);
System.exit(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should print the error statck before exit. Should we should update showConfigError and showFatalError

@@ -40,9 +40,11 @@ public static <T extends CommandArgs> void run(Command<T> command) throws Comman
command.execute();
} catch (ConfigRuntimeException e) {
showConfigError(e);
System.exit(1);
throw e;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw e;

showFatalError(e);
System.exit(1);
throw e;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw e;

Comment on lines 57 to 64
// Verify the exception message
Assertions.assertEquals(
String.format(
"No configuration setting found for key '%s'",
PLUGIN_NAME.key()),
e.getCause().getMessage());
// Re-throw to ensure the test fails if System.exit is not called
throw e;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the catch block will never reach. We can delete it.

SeaTunnel.run(clientCommandArgs.buildCommand());
} catch (CommandExecuteException e) {
// Verify the exception message
Assertions.assertEquals(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

SeaTunnel.run(sparkCommandArgs.buildCommand());
} catch (CommandExecuteException e) {
// Verify the exception message
Assertions.assertEquals(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET

Hisoka-X
Hisoka-X previously approved these changes May 13, 2025
Copy link
Member

@Hisoka-X Hisoka-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if ci passes. Thanks @CosmosNi

hailin0
hailin0 previously approved these changes May 13, 2025
@hailin0
Copy link
Member

hailin0 commented May 13, 2025

Please retry ci

@CosmosNi CosmosNi dismissed stale reviews from hailin0 and Hisoka-X via d978d14 May 14, 2025 01:07
hailin0
hailin0 previously approved these changes May 15, 2025
Comment on lines 151 to 157
// errors
// Assertions.assertTrue(
// execResult
// .getStderr()
// .contains(
// "ErrorCode:[API-11], ErrorDescription:[The sink table not
// exist]"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact we still should get error msg from execResult. Please check where we can get the error msg now?

@github-actions github-actions bot removed the e2e label May 16, 2025
public class SeaTunnelClientOOMTest {

@Test
public void testHazelcastOOMExitBehavior() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two test case are same. Any code missed update or we can keep one?

Copy link
Member

@Hisoka-X Hisoka-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if ci passes.

@hailin0 hailin0 merged commit d023cf2 into apache:dev May 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved core SeaTunnel core module reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug][Zeta] SeaTunnelClient can not exit with error
3 participants