Repository navigation
Conversation
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.
Summary
Implements Block A (Messaging, Resilience & SQLite concurrency) for
apps/apiand updatesdocs/JOB-QUEUE.md:SqlitePragmaConnectionInterceptorregistered onEchoDbContextto enforcePRAGMA busy_timeout = 5000;,PRAGMA foreign_keys = ON;, andPRAGMA synchronous = NORMAL;whenever EF Core opens a SQLite connection.PRAGMA journal_mode = WAL;andPRAGMA synchronous = NORMAL;on startup inApplicationBuilderExtensions.ApplyMigrationsAsync(guarded to file-backed relational SQLite databases, skipping:memory:).IJobDispatcherSignal/JobDispatcherSignalbacked by a bounded single-itemChannel<bool>(BoundedChannelFullMode.DropWrite) that coalesces concurrent wakeups without blocking.dispatcherSignal.Notify()after successful DB commits inCreateRecording,RetryTranscription, andCreateRefinement.RabbitJobServiceto split publishing (dedicated publisher-confirmed channel) and result consumption (dedicated consumer channel withBasicQosAsync(0, 10, false)andAsyncEventingBasicConsumer), preserving ack/DLQ-reject/nack semantics, reactive outbox wakeups withPollIntervalMsfallback, clean disconnect detection/reconnect backoff, and graceful shutdown.RabbitOptions.ProcessingTimeoutSeconds(default600, validated> 0on startup).JobDispatch.ReclaimStale(invoked before preparing new outbox entries) to reclaimProcessingtranscription and refinement jobs whose(UpdatedAt ?? CreatedAt)exceeds the timeout: jobs withAttemptCount < 3reset toCreatedfor re-dispatch with a freshClaimToken(ignoring late zombie results), and jobs withAttemptCount >= 3transition toFailedwith a timeout failure reason.docs/JOB-QUEUE.mdto document push-based result consumption, reactive outbox wakeups, SQLite WAL/concurrency pragmas, and lease-based stuck-job recovery.Architectural Trade-offs
synchronous = NORMALalongside startup WAL: SQLite persistsjournal_mode=WALin the DB header, whereassynchronous,busy_timeout, andforeign_keysare per-connection settings; applying them inDbConnectionInterceptorguarantees every pooled/new EF Core connection runs with consistent concurrency semantics.1) serializes SQLite result writes on the consumer channel with prefetch10buffering.Processinghangs (e.g., purged queues or permanently wedged workers) viaProcessingTimeoutSecondsandClaimTokenfencing.Verification
dotnet test apps/api/Echo.slnx— 28 passed, 0 failed, 0 skipped:SqlitePragmaTests: verifies WAL mode,synchronous=NORMAL,busy_timeout=5000,foreign_keys=ON(including FK violation rejection), and in-memory SQLite skip.JobDispatchTests: verifies stale transcription/refinement reclamation, re-dispatch with freshClaimToken, late zombie result rejection,AttemptCount >= 3timeout failure, and non-expired jobs remaining untouched.JobDispatcherSignalTests: verifies signal coalescing without blocking, immediate wakeup, timeout fallback, cancellation propagation, andProcessingTimeoutSeconds <= 0startup validation.StorageKeyMigrationTests.Disposeto clear SQLite pools before temp file deletion on Windows.