Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

Commit

Home's daily signal reads again: the weekly query stays within D1's compound SELECT limit

D1 takes at most five terms in one compound SELECT; SQLite allows 500. The stalled check read its eight activity sources in one UNION ALL, so D1 refused the weekly query with "too many terms in compound SELECT", the whole batch failed, and Home said what the work says couldn't be read. The sources are now read in two halves of four. The signals tests' databases set the same limit, so a statement they pass also runs on D1. Part of #162

G1t-Session:
ses_01m57128wre9bvvj1y4z4b8dk0
syntaqxcommitted Parent5fd08e6Browse files
3 files+15−40/3 viewed
+2−1
2323 sha2 = "0.10"
2424
2525 [dev-dependencies]
26−rusqlite = { version = "0.32", features = ["bundled"] }
26+# limits: the tests' databases refuse what D1 refuses (signals/tests.rs).
27+rusqlite = { version = "0.32", features = ["bundled", "limits"] }
2728
2829 # wasm-opt at -O1: about the same gzipped size as -O in a tenth of the
2930 # time.
+5−0
99
1010 const IDS: &str = r#"["a"]"#;
1111
12+/// D1 takes at most five terms in one compound SELECT; SQLite allows 500.
13+const D1_COMPOUND_SELECT: i32 = 5;
14+
1215 fn schema() -> Connection {
1316 let db = Connection::open_in_memory().unwrap();
17+ // Refuse what D1 refuses, so a statement these tests pass also runs there.
18+ db.set_limit(rusqlite::limits::Limit::SQLITE_LIMIT_COMPOUND_SELECT, D1_COMPOUND_SELECT);
1419 db.execute_batch(
1520 "CREATE TABLE pulls (id TEXT, repo_id TEXT, number INTEGER, title TEXT DEFAULT 'A change', status TEXT,
1621 item_id TEXT, milestone INTEGER, agent TEXT DEFAULT 'person', author_id TEXT DEFAULT 'usr_ana',
+8−3
4242 AND NOT (x.status = 'closed' AND COALESCE(x.u < cuts.lo, 0))
4343 ),
4444 -- What each of them saw, as spans [t0, t1] (a moment where t0 = t1).
45−-- CROSS JOIN keeps each read starting from the few candidates.
46−act(pull_id, t0, t1) AS MATERIALIZED (
45+-- CROSS JOIN keeps each read starting from the few candidates. D1 takes
46+-- at most five terms in one compound SELECT, so the sources are read in
47+-- two halves of four and joined.
48+act_a(pull_id, t0, t1) AS MATERIALIZED (
4749 -- Comments of every kind: reviews, and the timeline's events (labels,
4850 -- assignees, review requests, milestones, ready, draft, closed,
4951 -- reopened, base changes, the merge queue, auto-merge, branches deleted
5759 -- Its acceptance checks, from queued to finished.
5860 UNION ALL SELECT k.id, julianday(cr.created_at), julianday(COALESCE(cr.finished_at, cr.created_at))
5961 FROM cand k CROSS JOIN check_runs cr ON cr.pull_id = k.id
62+),
63+act_b(pull_id, t0, t1) AS MATERIALIZED (
6064 -- Statuses and check runs on its head commit, the one commit pulls keep
6165 -- (a status keeps only when it last changed).
62− UNION ALL SELECT k.id, julianday(st.updated_at), julianday(st.updated_at)
66+ SELECT k.id, julianday(st.updated_at), julianday(st.updated_at)
6367 FROM cand k CROSS JOIN commit_statuses st ON st.repo_id = k.repo_id AND st.sha = k.head_commit
6468 UNION ALL SELECT k.id, julianday(ck.created_at), julianday(ck.updated_at)
6569 FROM cand k CROSS JOIN commit_check_runs ck ON ck.repo_id = k.repo_id AND ck.head_sha = k.head_commit
7074 UNION ALL SELECT k.id, julianday(s.started_at), julianday(s.last_seen_at)
7175 FROM cand k CROSS JOIN tied t ON t.pull_id = k.id CROSS JOIN sessions s ON s.parent_id = t.session_id
7276 ),
77+act(pull_id, t0, t1) AS (SELECT * FROM act_a UNION ALL SELECT * FROM act_b),
7378 -- Each week a pull request saw something in the three days before its cut.
7479 busy AS MATERIALIZED (
7580 SELECT DISTINCT a.pull_id, w.start FROM act a JOIN w ON a.t0 < w.cut AND a.t1 >= w.cut - 3

Comments

Sign in to comment.