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

improvement CLDSRV-466 add timestamp for exceptions #5406

Merged

Conversation

tmacro
Copy link
Contributor

@tmacro tmacro commented Nov 2, 2023

Adds a timestamp to uncaught exceptions to aid in debugging.

@bert-e
Copy link
Contributor

bert-e commented Nov 2, 2023

Hello tmacro,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Status report is not available.

@scality scality deleted a comment from bert-e Nov 2, 2023
@bert-e
Copy link
Contributor

bert-e commented Nov 2, 2023

Request integration branches

Waiting for integration branch creation to be requested by the user.

To request integration branches, please comment on this pull request with the following command:

/create_integration_branches

Alternatively, the /approve and /create_pull_requests commands will automatically
create the integration branches.

@tmacro
Copy link
Contributor Author

tmacro commented Nov 2, 2023

/create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 2, 2023

Integration data created

I have created the integration data for the additional destination branches.

The following branches will NOT be impacted:

  • development/7.4

You can set option create_pull_requests if you need me to create
integration pull requests in addition to integration branches, with:

@bert-e create_pull_requests

The following options are set: create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 2, 2023

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following options are set: create_integration_branches

index.js Outdated
* Catch uncaught exceptions and add timestamp to aid debugging
*/
process.on('uncaughtException', err => {
process.stderr.write(`${new Date().toISOString()} ${err.stack}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the exception backtrace is multi-line, I'd recommend for readability to add short context info around the timestamp, followed by a newline, then the exception backtrace. This way the first backtrace line is aligned with the other lines.

Here's what I'm thinking about:

process.stderr.write(`${new Date().toISOString()}: Uncaught exception: \n${err.stack}`); 

/**
* Catch uncaught exceptions and add timestamp to aid debugging
*/
process.on('uncaughtException', err => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to also catch the rejections?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's been a long time but this does catch rejections as well

Comment on lines +4 to +8
* Catch uncaught exceptions and add timestamp to aid debugging
*/
process.on('uncaughtException', err => {
process.stderr.write(`${new Date().toISOString()}: Uncaught exception: \n${err.stack}`);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This will change the service behavior in case of error right? Like, we won't crash, and we won't end the current request either, is that what we want? Maybe I'm missing something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I thought too, but from observation he worker still exits after the message is printed.

Copy link
Contributor

Choose a reason for hiding this comment

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

old PR, but the worker exits because he adds its own listener (

process.on('uncaughtException', err => {
// If just send the error object results in empty
// object on server log.
logger.fatal('caught error', {
error: err.message,
stack: err.stack,
workerId: this.worker ? this.worker.id : undefined,
workerPid: this.worker ? this.worker.process.pid : undefined,
});
this.caughtExceptionShutdown();
) to shutdown after this one.

However the primary (that uses fork and has the monitoring server for prom metrics) don't have another listener, so this is keep the primary up in undefined state if an exception is caught

@tmacro tmacro force-pushed the improvement/CLDSRV-466/timestamps_in_stderr branch from 1f73366 to b1b2d2a Compare November 10, 2023 16:17
@tmacro
Copy link
Contributor Author

tmacro commented Nov 10, 2023

/reset

@scality scality deleted a comment from bert-e Nov 10, 2023
@bert-e
Copy link
Contributor

bert-e commented Nov 10, 2023

Reset complete

I have successfully deleted this pull request's integration branches.

The following options are set: create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 10, 2023

Integration data created

I have created the integration data for the additional destination branches.

The following branches will NOT be impacted:

  • development/7.4

You can set option create_pull_requests if you need me to create
integration pull requests in addition to integration branches, with:

@bert-e create_pull_requests

The following options are set: create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 10, 2023

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following options are set: create_integration_branches

@tmacro
Copy link
Contributor Author

tmacro commented Nov 13, 2023

/approve

@bert-e
Copy link
Contributor

bert-e commented Nov 13, 2023

In the queue

The changeset has received all authorizations and has been added to the
relevant queue(s). The queue(s) will be merged in the target development
branch(es) as soon as builds have passed.

The changeset will be merged in:

  • ✔️ development/7.10

  • ✔️ development/7.70

  • ✔️ development/8.6

  • ✔️ development/8.7

  • ✔️ development/8.8

The following branches will NOT be impacted:

  • development/7.4

There is no action required on your side. You will be notified here once
the changeset has been merged. In the unlikely event that the changeset
fails permanently on the queue, a member of the admin team will
contact you to help resolve the matter.

IMPORTANT

Please do not attempt to modify this pull request.

  • Any commit you add on the source branch will trigger a new cycle after the
    current queue is merged.
  • Any commit you add on one of the integration branches will be lost.

If you need this pull request to be removed from the queue, please contact a
member of the admin team now.

The following options are set: approve, create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Nov 13, 2023

I have successfully merged the changeset of this pull request
into targetted development branches:

  • ✔️ development/7.10

  • ✔️ development/7.70

  • ✔️ development/8.6

  • ✔️ development/8.7

  • ✔️ development/8.8

The following branches have NOT changed:

  • development/7.4

Please check the status of the associated issue CLDSRV-466.

Goodbye tmacro.

@bert-e bert-e merged commit 0882bff into development/7.10 Nov 13, 2023
10 checks passed
@bert-e bert-e deleted the improvement/CLDSRV-466/timestamps_in_stderr branch November 13, 2023 17:38
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.

6 participants