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

Bug/skaled 1623 sigterm at exit #1695

Merged
merged 10 commits into from
Nov 21, 2023

Conversation

dimalit
Copy link
Contributor

@dimalit dimalit commented Oct 17, 2023

When skaled is shutting down by internal cause, it counts this event as though it was external SIGTERM. This leads to forced shutdown if real SIGTERM is received during shutdown procedure. Need not to count internal exit request as SIGTERM.

Test https://github.com/skalenetwork/skale-node-tests/blob/master/test_stop.py#L252

@dimalit dimalit changed the base branch from develop to v3.18.0 October 17, 2023 18:49
@dimalit dimalit linked an issue Oct 17, 2023 that may be closed by this pull request
@dimalit
Copy link
Contributor Author

dimalit commented Oct 17, 2023

Probably, let's wait for "stable" - it will integrate changes in develop into v3.18.0 - and this PR would not be so bloated

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Merging #1695 (22eed15) into v3.18.0 (531ffac) will increase coverage by 7.75%.
Report is 53 commits behind head on v3.18.0.
The diff coverage is 64.35%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           v3.18.0    #1695      +/-   ##
===========================================
+ Coverage    37.54%   45.29%   +7.75%     
===========================================
  Files          349      351       +2     
  Lines        51408    51475      +67     
===========================================
+ Hits         19301    23316    +4015     
+ Misses       32107    28159    -3948     

std::string strMessagePrefix;
if ( nSignalNo > 0 ) {
strMessagePrefix = ( ExitHandler::shouldExit() && s_nStopSignal > 0 ) ?
cc::error( "\nStop flag was already raised on. " ) +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove color comments

strMessagePrefix = ExitHandler::shouldExit() ?
cc::error( "\nInternal exit requested while already exiting. " ) :
cc::error( "\nInternal exit initiated. " );
}
std::cerr << strMessagePrefix << cc::error( skutils::signal::signal2str( nSignalNo ) )
<< "\n\n";
std::cerr.flush();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this line since cerr is always flushed on line end

@@ -153,7 +160,8 @@ void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) {

// nice exit here:

if ( ExitHandler::shouldExit() ) {
// TODO deduplicate with first if()
if ( ExitHandler::shouldExit() && s_nStopSignal > 0 && nSignalNo > 0 ) {
std::cerr << ( "\n" + cc::fatal( "SIGNAL-HANDLER:" ) + " " +
cc::error( "Will force exit now..." ) + "\n\n" );
_exit( 13 );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is 13 used here ? Is there a document in which error codes are defined?

Copy link
Collaborator

@DmytroNazarenko DmytroNazarenko left a comment

Choose a reason for hiding this comment

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

Approved, next steps:

  1. Need to add test to functional-tests
  2. Fix colorization
  3. Test build on devnet

@dimalit
Copy link
Contributor Author

dimalit commented Nov 20, 2023

UPD Currently, functional tests fail in load_js. But fail happens because of skaled JSON-RPC request refusal. As changes in this PR cannot affect JSON-RPC at all - most probably, issue is because of Debug build instead of Release build. It should be gone after merge and Release build.

@DmytroNazarenko DmytroNazarenko merged commit 7571104 into v3.18.0 Nov 21, 2023
8 of 9 checks passed
@DmytroNazarenko DmytroNazarenko deleted the bug/SKALED-1623-sigterm-at-exit branch November 21, 2023 13:16
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIGETRM during shutdown forces shutdown
3 participants