Skip to content

Improve Library - #4

Merged
Drakonian merged 2 commits into
mainfrom
ImproveLibrary
Jul 10, 2026
Merged

Drakonian merged 2 commits into
mainfrom
ImproveLibrary

Conversation

@Drakonian

Copy link
Copy Markdown
Owner

README (critical)

  • Worker examples crashed at runtime — JsonArray is 0-based, but both
    examples iterated 1..Count. Rewritten with foreach.
  • Fixed doc/code mismatches: RunAndWait* keeps batch records by default,
    partial-failure results are returned, documented AutoCleanup/Errors
    overloads, null-GUID return for empty input, missing Commit() in the retry
    example, new Known Constraints (stable record sets, reserved $ keys).

Liveness — batch can no longer get stuck in Running

  • Dead-session check is now periodic (was one-shot), so sessions that die
    late are still recovered.
  • StartBatch persists each chunk's session id, so recovery also covers
    Pending chunks whose session died before reaching Running.
  • WaitForCompletion reconciles stalled counters when every chunk is
    terminal but the batch row still says Running (dispatcher died between its
    two final commits).

Robustness

  • Dispatcher claims chunks under UpdLock and only if Pending — removes write
    races with the coordinator and recovery.
  • Recovery re-checks chunk status under UpdLock before failing it — no more
    potential concurrency error in the caller.
  • Cleanup during a live batch is now safe (guarded re-reads everywhere).
  • Unset session timeout now uses the StartSession overload without the
    timeout parameter (explicit 0 was undocumented platform behavior).
  • GetErrors preserves multi-line error text (was truncated to first line).
  • GetRecordRef fails loudly when the record set changed since batch creation.
  • CleanupOlderThan no longer overflows for large hour values; set-based delete.
  • Validation: SetThreads(<1) errors; $-prefixed payload keys rejected;
    SetResult/AppendResult require an initialized context.

⚠️ Behavior change

WaitForCompletion now errors if called inside a write transaction (its
recovery paths commit internally — previously this could silently commit caller
changes).

Tests

17 new tests: stalled-counter reconciliation, dead Running/Pending chunk
recovery, write-transaction guard, config/payload validation, multi-line errors,
record-range validation, cleanup overflow, session-id persistence, and
mid-batch cleanup safety. Both apps compile clean with all analyzers.

Drakonian added 2 commits July 4, 2026 21:13
  runtime); fixed doc/code mismatches around RunAndWait* and cleanup
- Recover dead sessions periodically (was one-shot) and cover Pending
  chunks by persisting session ids at batch start
- Reconcile stalled batch counters so WaitForCompletion cannot hang
- Claim/recover chunks under UpdLock; make Cleanup safe mid-batch
- Use server-default session timeout instead of undocumented explicit 0
- Preserve multi-line errors in GetErrors; validate record ranges,
  thread count, and reserved $ payload keys; fix cleanup hour overflow
- BREAKING: WaitForCompletion now errors inside a write transaction
- Add 17 tests covering each fix
@Drakonian
Drakonian merged commit be4ce07 into main Jul 10, 2026
5 checks passed
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