47:51Ranking major U.S. Open-Weights Models. (Where does Ripple 65B fit in?)
Nov 6, 2026 · YouTube
10:57"Crouton Alpha": the latest super-efficient coding model by Meta?
Nov 3, 2026 · YouTube
38:58Testing Particle-1: a post-trained DeepSeek V4.1 Flash specializing in coding and efficiency
Oct 28, 2026 · YouTube
16:45DeepSeek V4.1 Flash Is Shockingly Good for the Price
Sep 10, 2026 · YouTube
17:31Testing Gemini 3.8 Flash on Real Coding Challenges (vs. other models)
Sep 2, 2026 · YouTube
17:37Tencent Hy4 Preview Tested: Is It Really Better Than Kimi K3 and GLM 5.3?
Aug 28, 2026 · YouTube
23:58Qwen 3.8 Flash Tested: UI, Coding, Physics & more - compared to Opus 5, Sol Pro, Grok
Aug 27, 2026 · YouTube
14:50Stealth Ox Alpha: a new GLM model! Full test (coding & writing) against Grok, Gemini, GPT & others
Aug 21, 2026 · YouTube
21:54GLM 5.3 Tested: Does it beat Claude Opus 5 & Grok 4.6?
Aug 19, 2026 · YouTube
You are the engineer on call. Three tickets have come in against the comment feed. Some of them are bugs. Some of them may not be.
Your job is triage and a minimal fix — not a rewrite.
FEED-441 — opened by Ama (Support)
Comments are appearing on page 1 and then again on page 2. Different comments go missing entirely — a user linked us a comment of their own that they cannot find by paging through the thread it is in, and it is definitely still there, the direct link works.
Worst on the big threads. The busy live ones are unusable.
FEED-455 — opened by Ama (Support)
Four users this week with a completely empty feed. Not slow — empty. "No comments yet" on threads with thousands.
All four are long-standing accounts. The only thing I can find in common is that they all use the block feature a lot. One of them has 200-odd blocks. A brand new account with no blocks has never reported this.
FEED-460 — opened by Dev (Ops)
Sort order is broken on page 1. Newest first is the entire point of this feed and I am looking at a thread whose top comment is from March. Scroll down and the rest of the page is correctly ordered, newest at the top of the remainder. Just that one at the top is wrong.
Comment on FEED-455 from Sam (Data), 2 days ago
Seen this before at my last place. It is the connection pool —
pgdefaults to 10 clients and we are saturating it under load, so some queries come back partial instead of erroring. That is also why it looks random. Bumpmaxto 50 and add a statement timeout.
CREATE TABLE users (
id uuid PRIMARY KEY,
handle text NOT NULL UNIQUE,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE threads (
id uuid PRIMARY KEY,
title text NOT NULL
);
CREATE TABLE comments (
id uuid PRIMARY KEY,
thread_id uuid NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
author_id uuid NOT NULL REFERENCES users(id),
body text NOT NULL,
is_pinned boolean NOT NULL DEFAULT false,
is_deleted boolean NOT NULL DEFAULT false,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX comments_thread_created_idx
ON comments (thread_id, created_at DESC);
CREATE TABLE blocks (
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
-- Nulled rather than deleted when the blocked account is removed, so the
-- block survives an account being recreated on the same handle.
blocked_user_id uuid REFERENCES users(id) ON DELETE SET NULL,
created_at timestamptz NOT NULL DEFAULT now()
);
/**
* feed/comments.ts — the comment feed query. Serves the thread view and the
* mobile API. Roughly 4k requests/second at peak.
*/
import { Pool } from "pg";
import { logger } from "../logger";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const PAGE_SIZE = 20;
export interface Comment {
id: string;
authorHandle: string;
body: string;
isPinned: boolean;
createdAt: Date;
}
export interface Page {
comments: Comment[];
/** Total matching this thread + viewer, for the "N comments" header. */
total: number;
hasMore: boolean;
}
/**
* One page of a thread, as seen by one viewer.
*
* `page` is 1-based and comes straight off the query string.
*/
export async function getCommentPage(
threadId: string,
viewerId: string,
page: number
): Promise<Page> {
const offset = (Math.max(1, page) - 1) * PAGE_SIZE;
const rows = await pool.query<{
id: string;
handle: string;
body: string;
is_pinned: boolean;
created_at: Date;
}>(
`SELECT c.id, u.handle, c.body, c.is_pinned, c.created_at
FROM comments c
JOIN users u ON u.id = c.author_id
WHERE c.thread_id = $1
AND c.is_deleted = false
AND c.author_id NOT IN (
SELECT b.blocked_user_id
FROM blocks b
WHERE b.user_id = $2
)
ORDER BY c.is_pinned DESC, c.created_at DESC
LIMIT $3 OFFSET $4`,
[threadId, viewerId, PAGE_SIZE, offset]
);
const counted = await pool.query<{ count: string }>(
`SELECT count(*) AS count
FROM comments c
WHERE c.thread_id = $1
AND c.is_deleted = false`,
[threadId]
);
const total = Number(counted.rows[0].count);
logger.debug("feed page served", {
threadId,
viewerId,
page,
returned: rows.rowCount,
total,
});
return {
comments: rows.rows.map((r) => ({
id: r.id,
authorHandle: r.handle,
body: r.body,
isPinned: r.is_pinned,
createdAt: r.created_at,
})),
total,
hasMore: offset + rows.rowCount < total,
};
}
A table with one row per ticket, in order:
| Ticket | Verdict | Cause |
|---|---|---|
| FEED-441 | ||
| FEED-455 | ||
| FEED-460 |
Verdict is exactly one of REAL or NOT A BUG. Cause is one line — for a real bug, what is actually wrong; for a non-bug, what the reporter is actually looking at and why the code above does not have the defect they describe.
One paragraph on Sam's connection-pool explanation. Right, partly right, or wrong — and if wrong, say what a saturated pg pool actually does to a query, because it is not what he says it does.
For each ticket you marked REAL, and only those:
For FEED-441 specifically, if the correct fix changes the shape of the API rather than one line, say so plainly and give the smallest version of it you would actually ship.
Do not give me the whole file back.
At most two further defects nobody has reported, each one you can quote a line for.
If there is nothing else worth raising, write exactly Nothing else.
Every claim should be checkable against the schema and the code above, or against documented PostgreSQL behavior you can state exactly. One of these bugs turns on a rule about how SQL evaluates a specific operator — if that is your diagnosis, state the rule, do not just name it. A confident diagnosis of a bug that is not here costs you more than missing one that is.
| Ticket | Verdict | Cause |
|---|---|---|
| FEED-441 | REAL | LIMIT/OFFSET paging over a non-total sort order: ORDER BY c.is_pinned DESC, c.created_at DESC has no unique tiebreaker, so rows sharing a created_at may be returned in a different order on each request (duplicates/omissions across pages), and on live threads new inserts shift every row's offset between page fetches, which drops rows past a page boundary and repeats others. |
| FEED-455 | REAL | c.author_id NOT IN (SELECT b.blocked_user_id ...) — blocks.blocked_user_id is nullable by design (ON DELETE SET NULL), and a single NULL in that subquery makes the predicate UNKNOWN for every row, so the whole feed is filtered out. Heavy blockers are the users most likely to have blocked an account that was later deleted; a zero-block account has an empty subquery, which is safe. |
| FEED-460 | NOT A BUG | He is looking at a pinned comment. ORDER BY c.is_pinned DESC is the first sort key, so is_pinned = true rows sort ahead of all others regardless of age — and only on page 1, with the remainder still strictly created_at DESC, which is exactly what he describes. The query is doing what it was written to do; isPinned is already in the response payload, so the gap is that the client isn't rendering the pin badge. |
Wrong, and worth closing out explicitly so nobody bumps max and calls FEED-455 fixed. pg's Pool does default to max: 10, but saturation does not produce partial results. When all clients are checked out, pool.query() does not touch the database at all — the acquisition request is queued in memory, and with the default connectionTimeoutMillis: 0 it waits indefinitely (set it, and you get a thrown Error: timeout exceeded when trying to connect, not rows). Once a client is acquired, the extended-query protocol delivers DataRow messages until CommandComplete; a connection lost mid-stream surfaces as a rejected promise or a Client has encountered a connection error, never as a short result set that resolves successfully. So the observable symptoms of a saturated pool are latency and errors, and both are thread-wide, not per-viewer. The correlation Ama found — four heavy blockers, never the zero-block account — is a per-viewer data dependency, which load cannot explain. A statement timeout is fine hygiene; it is not this.
FEED-455
Wrong, verbatim:
AND c.author_id NOT IN (
SELECT b.blocked_user_id
FROM blocks b
WHERE b.user_id = $2
)
Replacement:
AND NOT EXISTS (
SELECT 1
FROM blocks b
WHERE b.user_id = $2
AND b.blocked_user_id = c.author_id
)
The rule: x NOT IN (subquery) is defined as NOT (x = ANY (subquery)), i.e. x <> s1 AND x <> s2 AND ... AND x <> sn. x <> NULL evaluates to UNKNOWN, not FALSE. If x matches none of the non-null values but one si is NULL, the conjunction is TRUE AND ... AND UNKNOWN = UNKNOWN, and WHERE admits only rows where the predicate is TRUE — so every comment is discarded. (An empty subquery is the special case that works: = ANY over zero rows is FALSE, so NOT IN is TRUE — hence the clean new account.) NOT EXISTS cannot do this: a blocks row with a NULL blocked_user_id simply fails the join predicate and produces no row, so the comment is kept. AND b.blocked_user_id IS NOT NULL inside the old NOT IN would also work, but NOT EXISTS removes the footgun permanently.
FEED-441
Wrong, verbatim:
ORDER BY c.is_pinned DESC, c.created_at DESC
LIMIT $3 OFFSET $4
Yes — the correct fix changes the shape of the API, and I'd say so on the ticket rather than pretend otherwise. A tiebreaker alone (ORDER BY c.is_pinned DESC, c.created_at DESC, c.id DESC) makes the order total and fixes the equal-timestamp duplicates, which is a one-line change worth taking regardless. It does not fix the busy-thread case, because with OFFSET the window is defined by position: any comment inserted while the user is on page 1 pushes one row from the bottom of page 1 to the top of page 2 (duplicate) and, in the delete/paging direction, hides one entirely. That is the "unusable on live threads" report and no ORDER BY fixes it. page: number has to become a cursor.
Smallest version I'd ship — keyset paging, same one query, page replaced by an opaque cursor:
AND ($3::uuid IS NULL
OR (c.is_pinned, c.created_at, c.id) < ($4::boolean, $5::timestamptz, $3::uuid))
ORDER BY c.is_pinned DESC, c.created_at DESC, c.id DESC
LIMIT $6
with [threadId, viewerId, cursorId ?? null, cursorIsPinned ?? null, cursorCreatedAt ?? null, PAGE_SIZE + 1], the signature becoming (threadId, viewerId, cursor?: string), Page gaining nextCursor: string | null, and hasMore derived from whether the PAGE_SIZE + 1-th row came back (then dropped before mapping) instead of from total. Encode the cursor as base64 of id|createdAt|isPinned from the last returned row.
Why it fixes it: PostgreSQL row-constructor comparison is lexicographic, element by element, so (is_pinned, created_at, id) < (cursor...) is exactly "strictly after the cursor row in the is_pinned DESC, created_at DESC, id DESC ordering" — booleans order false < true, so < correctly keeps unpinned-after-pinned. Each page is defined by which row you last saw, not by a count of rows ahead of it, so concurrent inserts and deletes can no longer shift the window, and the id component guarantees a unique, stable position for every row.
/** Total matching this thread + viewer, for the "N comments" header. */): WHERE c.thread_id = $1
AND c.is_deleted = false
total is therefore thread-wide, not viewer-specific, so a heavy blocker sees an inflated "N comments" header and, worse, hasMore: offset + rows.rowCount < total stays true past the real end of their feed — an endless "load more" that returns nothing. Add the same NOT EXISTS clause here, or (better, with the keyset fix above) stop deriving hasMore from total at all.
blocks has no primary key and no index:CREATE TABLE blocks (
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
At 4k req/s the block lookup is a sequential scan of the whole table per request, and nothing prevents duplicate (user_id, blocked_user_id) rows. Add CREATE INDEX blocks_user_idx ON blocks (user_id, blocked_user_id);. Related: comments_thread_created_idx (thread_id, created_at DESC) does not match the is_pinned DESC, created_at DESC, id DESC sort, so every page requires a sort of the thread's matching rows — (thread_id, is_pinned DESC, created_at DESC, id DESC) lets the keyset query walk the index directly.