Skip to content

gh-154194: Degrade frames in Tachyon instead of failing the sample - #154195

Merged
pablogsal merged 13 commits into
python:mainfrom
maurycy:tachyon-degrade-gracefully
Oct 5, 2026
Merged

pablogsal merged 13 commits into
python:mainfrom
maurycy:tachyon-degrade-gracefully

Conversation

@maurycy

@maurycy maurycy commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

As always, see #154194 for the context. Shortly: right now remote inspection fails the whole sample when it hits the limits (and we're really not sure what are the best limits) OR always when reading a part fails. This is too strict, wasteful and introduces scary bias, as observed in https://discuss.python.org/t/tachyon-97-error-rate/107619.

The PR introduces graceful degradation with the sentinels like <unreadable frame> (funcname), <unknown function> (funcname), <unknown file> (filename). Also, attemps to better differentiate between transient failures in _Py_RemoteDebug_IsFatalReadError().

Importantly: degraded frames are never cached, while the truncated strings are cached.

@maurycy
maurycy marked this pull request as ready for review July 19, 2026 20:17
@maurycy
maurycy requested a review from pablogsal as a code owner July 19, 2026 20:17
@maurycy

maurycy commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor Author

I believe that the CI failures are caused by the fact that test_async_aware_running_sees_only_cpu_task does not terminate. It worked only because a torn read caused an exception. That's what inspired #153365 in the first place.

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still need more time but some nits

Comment thread Modules/_remote_debugging/object_reading.c Outdated
Comment thread Misc/NEWS.d/next/Library/2026-07-19-22-08-05.gh-issue-154194.1bqRdx.rst Outdated
@maurycy maurycy changed the title gh-154194: Do not fail the whole sample in Tachyon if we can degrade gh-154194: Degrade frames in Tachyon instead of failing the sample Jul 21, 2026
Comment thread Lib/asyncio/tools.py
# Build coroutine stack string
frames = [frame for coro in task_info.coroutine_stack
for frame in coro.call_stack]
coro_stack = " -> ".join(_format_stack_entry(x).split(" ")[0]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This does not work for the <unknown function> sentinel.

Comment thread Lib/asyncio/tools.py
Comment on lines 28 to 29
def _format_stack_entry(elem: str|FrameInfo) -> str:
if not isinstance(elem, str):

@maurycy maurycy Jul 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe that isinstance(elem, str) is dead since #135436. Perhaps we should clean this defensive code everywhere.

Comment thread Lib/asyncio/tools.py
# ─── indexing helpers ───────────────────────────────────────────
def _format_stack_entry(elem: str|FrameInfo) -> str:
if not isinstance(elem, str):
if elem.location is None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Regular collectors rely on these helpers:

if location is None:
return 0

if location is None:
return DEFAULT_LOCATION

PyObject *func = NULL;
PyObject *file = NULL;
PyObject *linetable = NULL;
int code_metadata_incomplete = 0;

@maurycy maurycy Jul 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Perhaps parse_code_object() should return this information, and we should not store incomplete objects in the frame_cache?

Perhaps we should collect degradation stats? Important caveat is that we will likely have more types of degradation.

Comment on lines +636 to +640
"<GC>",
"<native>",
"<unknown function>",
"<unknown file>",
"<unreadable frame>",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Perhaps we could add something like is_synthetic to FrameInfo?

@maurycy

maurycy commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

@pablogsal I've synced with main, and removed the (len=) suffix. The #157790 did not include it. #153365 still needs to go first, because of #154195 (comment)

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@pablogsal
pablogsal enabled auto-merge (squash) October 5, 2026 00:09
@pablogsal
pablogsal merged commit 7d25916 into python:main Oct 5, 2026
57 of 58 checks passed
@maurycy
maurycy deleted the tachyon-degrade-gracefully branch October 5, 2026 04:28
@pablogsal pablogsal added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Oct 5, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @maurycy for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @maurycy and @pablogsal, I could not cleanly backport this to 3.15 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 7d25916b41de4fc28e04b4944864ad1094a9e8e0 3.15

@bedevere-app

bedevere-app Bot commented Oct 5, 2026

Copy link
Copy Markdown

GH-158831 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Oct 5, 2026
@bedevere-app

bedevere-app Bot commented Oct 5, 2026

Copy link
Copy Markdown

GH-158833 is a backport of this pull request to the 3.14 branch.

pablogsal added a commit that referenced this pull request Oct 5, 2026
…mple (GH-154195) (#158831)

* gh-154194: Degrade frames in Tachyon instead of failing the sample (#154195)

* degrade gracefully

* news

* better NEWS wording

* do not raise on MAX_REMOTE_STR_READ

* bye MAX_REMOTE_STR_READ

* fix -m asyncio ps|pstree

* test truncation and linetable sentinel

* simpler

* simpler

* redundant now

* respect #157790 in the news

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
(cherry picked from commit 7d25916)

* Preserve the stable ABI when creating fallback frame names

---------

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
pablogsal added a commit that referenced this pull request Oct 5, 2026
…4195) (#158833)

* gh-154194: Degrade unreadable frames on 3.14

(cherry picked from commit 7d25916)

Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>

* Preserve the stable ABI when creating fallback frame names

---------

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.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.

2 participants