Skip to content

fix(logs): add logs flush on crash#1404

Merged
supervacuus merged 30 commits into
masterfrom
joshua/fix/logs_on_crash
Oct 20, 2025
Merged

fix(logs): add logs flush on crash#1404
supervacuus merged 30 commits into
masterfrom
joshua/fix/logs_on_crash

Conversation

@JoshuaMoelans
Copy link
Copy Markdown
Member

Fixes #1403

Part of #1398

@JoshuaMoelans JoshuaMoelans marked this pull request as ready for review October 3, 2025 12:30
cursor[bot]

This comment was marked as outdated.

Comment thread src/sentry_logs.c
cursor[bot]

This comment was marked as outdated.

…crash

# Conflicts:
#	CHANGELOG.md
#	tests/test_integration_crashpad.py
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Collaborator

@supervacuus supervacuus left a comment

Choose a reason for hiding this comment

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

LGTM ❤️

The only thing I ask you to do now is to reduce the logs or move them to the TRACE level.

this means when it does its clearing a TEST_CHECK cannot assume that a directory even exists (in which case clear_crash_marker would actually fail versus the case were only the marker file didn't exist).
cursor[bot]

This comment was marked as outdated.

@supervacuus
Copy link
Copy Markdown
Collaborator

@JoshuaMoelans, do you still want to add something here, or is this ready to merge from your point of view?

@JoshuaMoelans
Copy link
Copy Markdown
Member Author

@supervacuus good to go from my perspective! 🚀

@supervacuus supervacuus merged commit 781bfc3 into master Oct 20, 2025
40 checks passed
@supervacuus supervacuus deleted the joshua/fix/logs_on_crash branch October 20, 2025 10:34
BernhardMarconato pushed a commit to elgatosf/sentry-native that referenced this pull request Apr 21, 2026
* Add logs-on-crash

* skip crashpad test on macos

* add straight-to-disk writing of log envelopes if crashing

* CHANGELOG.md

* restore thread join for normal shutdown

* directly take log item from httpserver log for crashpad test

* update CHANGELOG.md

* we know which envelope has the log

* we **don't** know which envelope has the log

* add more general request fetch from httpserver function

* add logs return value checks

* fix tsan global data race on logs validation

* move database-path cleanup into the cmake build cache fixture

this eliminates boilerplate noise in the tests but also reduces the chance of forgetting it in a test.

* in the crash-safe logs flush detach the batcher thread and don't wake it since we flush anyway.

* don't clean for unit-test crash_marker

* don't detach in crash-safe but spin-lock in its flusher to acquire flushing.

* add clean parameter to cmake fixture

* ensure logs flushing in crash handlers happens within the handler sync bounds.

* bound the spin lock in the logs flusher during crash-safe mode

* exclude crashed_last_run unit-test from cleaning database paths

* use an unsigned integer for the sleep_time of the crash-safe logs flusher spinlock

* provide cross-platform cpu_relax and replace syscall sleep with spinners.

* isolate `crash_marker` unit test and eliminate exceptions to database cleaning in the pytest configuration

* platform path special case in crash_marker unit test

* crashed_last_run can no longer assume that a database path exists

this means when it does its clearing a TEST_CHECK cannot assume that a directory even exists (in which case clear_crash_marker would actually fail versus the case were only the marker file didn't exist).

* clean up log statements

* bump CI python to 3.12

* fix CHANGELOG.md

---------

Co-authored-by: Mischan Toosarani-Hausberger <mischan@abovevacant.com>
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.

Structured Logs: follow up - ensure logs get sent/cached to disk on crash

2 participants