mirror of
https://github.com/openai/codex.git
synced 2026-11-12 22:42:36 +00:00
Dispatch queued messages written by other processes (#39034)
## Why Durable thread queues can be updated through another SQLite connection, but loaded idle threads need to notice those updates before they can dispatch the new messages. ## What changed - Track a durable revision for each thread queue, including backfilling existing queues and updating revisions on inserts, updates, and deletes. - Poll SQLite's data version and query revisions to find changed queues for loaded threads. - Wake idle threads with pending external messages, discover queued work when threads are loaded or resumed, and retry each thread independently so one blocked queue does not stall others. ## Testing - Cover cross-runtime queue writes, edits, independent dispatch, wake retries, and resumed threads. - Cover migration backfills and revision tracking for queue updates and deletes. GitOrigin-RevId: 906d902bbf6a760be206a1b2c08fd71427b63c46
This commit is contained in:
1 parent
a8525b139c
commit
eeb82a156d
7 files changed
+552
-4
No files matched your search
@@ -0,0 +1,34 @@
|
||||
CREATE TABLE queued_thread_revisions (
|
||||
revision INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
thread_id TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
INSERT INTO queued_thread_revisions (thread_id)
|
||||
SELECT DISTINCT thread_id FROM queued_items ORDER BY thread_id;
|
||||
|
||||
CREATE TRIGGER queued_items_revision_after_insert
|
||||
AFTER INSERT ON queued_items
|
||||
BEGIN
|
||||
INSERT INTO queued_thread_revisions (thread_id)
|
||||
VALUES (NEW.thread_id)
|
||||
ON CONFLICT(thread_id) DO UPDATE
|
||||
SET revision = (SELECT COALESCE(MAX(revision), 0) + 1 FROM queued_thread_revisions);
|
||||
END;
|
||||
|
||||
CREATE TRIGGER queued_items_revision_after_update
|
||||
AFTER UPDATE ON queued_items
|
||||
BEGIN
|
||||
INSERT INTO queued_thread_revisions (thread_id)
|
||||
VALUES (NEW.thread_id)
|
||||
ON CONFLICT(thread_id) DO UPDATE
|
||||
SET revision = (SELECT COALESCE(MAX(revision), 0) + 1 FROM queued_thread_revisions);
|
||||
END;
|
||||
|
||||
CREATE TRIGGER queued_items_revision_after_delete
|
||||
AFTER DELETE ON queued_items
|
||||
BEGIN
|
||||
INSERT INTO queued_thread_revisions (thread_id)
|
||||
VALUES (OLD.thread_id)
|
||||
ON CONFLICT(thread_id) DO UPDATE
|
||||
SET revision = (SELECT COALESCE(MAX(revision), 0) + 1 FROM queued_thread_revisions);
|
||||
END;
|
||||
Reference in new issue
Block a user