Skip to content

test(python): synchronize live tenant allocations - #2952

Merged
chaliy merged 1 commit into
mainfrom
maintenance/asan-tenant-test-2026-11-18
Nov 18, 2026
Merged

chaliy merged 1 commit into
mainfrom
maintenance/asan-tenant-test-2026-11-18

Conversation

@chaliy

@chaliy chaliy commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Synchronize the Python tenant-isolation fixtures through host callbacks. Four tenants each hold 20 MiB before any are released.
  • Keep three neighbors’ allocations live while the greedy tenant exceeds its 32 MiB limit. Wait for both synchronization points within the test budget.

Before and after

Under AddressSanitizer, the previous fixture timed out at 20 seconds while spinning to keep its allocations live. Nightly log

All eight tenant-isolation tests passed locally with the Python feature enabled. The standard build took 0.84 seconds, and the AddressSanitizer build took 4.94 seconds with Nightly’s Rust toolchain and sanitizer settings.

Risk

Test fixtures only. The assertions still cover per-tenant memory accounting and rejection of an over-limit call.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@bashkit-pr-reviewer

Copy link
Copy Markdown

Review summary (PR #2952)

Verdict: Looks good — test-only change, no findings, nothing blocking.

What changed: crates/bashkit/tests/integration/python_tenant_isolation_tests.rs (sole file; diff was complete, not truncated). Both tenant-isolation tests replace the 3M-iteration CPU spin used to keep per-tenant 20 MiB / 8 MiB Python allocations alive with a host-callback rendezvous: a wait_for_tenants external function registered via python_with_external_handler, backed by tokio::sync::Barrier + tokio::time::timeout (TENANT_TIMEOUT 20 s).

Checks:

  • Barrier accounting is correct in both tests. Test 1: Barrier::new(4), exactly 4 tenant tasks wait once; the main task does not participate. Test 2: Barrier::new(4), each generation has exactly 4 arrivals (3 neighbors + main), twice; the over-limit greedy tenant uses a plain tenant() with no handler and never touches the barrier. tokio::sync::Barrier is reusable across generations, so this is sound.
  • Allocation-liveness argument holds: x is allocated before the wait_for_tenants() calls and referenced after them in print, so the interpreter must keep it live across both rendezvous points; the second generation in test 2 brackets the greedy 64 MiB over-limit attempt, preserving the original assertion (neighbors unaffected, greedy gets MemoryError).
  • Failure modes degrade to a clear assertion/timeout rather than a hang: a per-tenant-accounting regression means tenants fail before reaching the barrier and each exec still bounded by max_duration(TENANT_TIMEOUT); a sync failure surfaces via the expect("tenant sync ...") messages.
  • No production code touched, no sandbox/VFS boundary crossed, no new error paths in the interpreter — threat model and knowledge/ docs are unaffected. Test-only, so no new unit tests are owed (this is the test fix for the nightly ASan 20 s spin timeout cited in the description).

Context read beyond the diff: AGENTS.md, the full head version of the test file, and the python_with_external_handler builder plumbing (handler is cloned per python/python3 builtin, consistent with sharing one barrier Arc across tenants).

Could not review: nothing outstanding. (Per project rules I did not build or run tests — no cargo in this shell — so the local 0.84 s / ASan 4.94 s runs cited in the PR description are taken from the author.)

@chaliy
chaliy merged commit d1b6587 into main Nov 18, 2026
51 checks passed
@chaliy
chaliy deleted the maintenance/asan-tenant-test-2026-11-18 branch November 18, 2026 21:53
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.

1 participant