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

Fix/stop core on components startup exception #7021

Conversation

kozlovsky
Copy link
Contributor

@kozlovsky kozlovsky commented Aug 29, 2022

Fixes #7013. Stops Tribler Core on Session component's startup exception. Returns non-zero exit code from the Core process.

@@ -280,7 +280,7 @@ def event_from_exception(self, exception) -> Dict:
Returns:
the event that has been saved in `_before_send` method
"""
self._logger.info(f"Event from exception: {exception}")
self._logger.debug(f"Event from exception: {exception}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To avoid spamming logs with multiple copies of the same error traceback

Copy link
Contributor

Choose a reason for hiding this comment

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

NIT. As an alternative option, you can use SentryReporter.ignore_logger()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understand it, SentryReporter.ignore_logger() affects what we send to Sentry, but does not affect our log files.

self.last_core_stdout_output: str = ''
self.last_core_stderr_output: str = ''
self.last_core_stdout_output: deque = deque(maxlen=CORE_OUTPUT_DEQUE_LENGTH)
self.last_core_stderr_output: deque = deque(maxlen=CORE_OUTPUT_DEQUE_LENGTH)
Copy link
Contributor Author

@kozlovsky kozlovsky Aug 29, 2022

Choose a reason for hiding this comment

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

The last write to stderr does not necessarily contain the actual exception traceback, so we store several writes.

Comment on lines -209 to -210
quoted_output = re.sub(r'^', '> ', last_core_output, flags=re.MULTILINE)
message += f"\n\nLast core output:\n{quoted_output}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR moves the rendering of the last core output to gui_error, as we need it not only for CoreCrashedError but for other subclasses of CoreError as well, for example, for CoreConnectTimeoutError.

@kozlovsky kozlovsky force-pushed the fix/stop_core_on_components_startup_exception branch from 9d8a4f7 to a835472 Compare August 29, 2022 14:56
@kozlovsky kozlovsky marked this pull request as ready for review August 29, 2022 15:03
@kozlovsky kozlovsky requested review from a team, xoriole and drew2a and removed request for a team August 29, 2022 15:03
@@ -280,7 +280,7 @@ def event_from_exception(self, exception) -> Dict:
Returns:
the event that has been saved in `_before_send` method
"""
self._logger.info(f"Event from exception: {exception}")
self._logger.debug(f"Event from exception: {exception}")
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT. As an alternative option, you can use SentryReporter.ignore_logger()

@kozlovsky kozlovsky merged commit 28e5dfd into Tribler:release/7.12 Aug 30, 2022
@kozlovsky kozlovsky deleted the fix/stop_core_on_components_startup_exception branch August 30, 2022 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants