Repository navigation
refactor: one seconds-interval helper; coverage tracks greenlet switches - #242
Merged
Merged
Conversation
Benchmark gate✅ gate passed
Gated (fails the build): |
SQLAlchemy's async layer runs each statement in a greenlet, and the tracer drops lines that run after an untracked switch. On Python 3.11, which can't use sysmon, test_batched_flush_dlq_row_stays_inline lost a line in about a third of runs and failed the 100% gate.
lesnik512
force-pushed
the
refactor/seconds-interval
branch
from
October 17, 2026 19:18
f4f2cf1 to
bf2da54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cosmetic, no issue. The three
make_interval(0, 0, 0, 0, 0, 0, :param)calls inclient.pynow go through one_seconds(name)helper:activate_in;mark_pending_with_lease's retry delay.Two comments that explained the six zeros and the clock-skew reason are folded into its docstring.
Why not
make_interval(secs => ...)That was the original idea. SQLAlchemy's
funchas no named-argument form, so it would need a custom compiled element. It would also change the SQL text, which moves thepg_stat_statementsquery ids the benchmark gate counts. The helper keeps the SQL byte for byte.Verification
main's.just bench-checkpasses, which also coversmark_pending_with_lease.ruffandtyare clean.Also in this PR: coverage tracks greenlet switches
This PR's
pytest (3.11)job failed twice in a row, though all 744 tests passed both times. The coverage gate reportedtests/test_integration.py:1512as never run. That line is a publish loop intest_batched_flush_dlq_row_stays_inline, and the PR doesn't touch it.Main has the same flake. I ran that test 15 times under coverage and counted the runs that reported line 1512 missed:
concurrency = ["greenlet", "thread"], on 3.11, 3.12 and 3.13Cause: SQLAlchemy's async layer runs every statement in a greenlet. Coverage's C tracer loses its place across a greenlet switch it isn't tracking, so a line that runs after
await session.execute(...)can go unrecorded. #235 worked around this withcore = "sysmon", but Python 3.11 has nosys.monitoring, so the 3.11 job kept the C tracer and the flake.The change:
[tool.coverage.run]now setsconcurrency = ["greenlet", "thread"]and dropscore = "sysmon"and itsno-sysmonwarning filter.sysmonwith greenlet tracking. It falls back to the C tracer with ano-sysmonwarning, and the old filter would have hidden that. Every version now uses the same tracer.just test-branchmisses 16 partial branches against main's 20. The tracer was dropping those 4 too.