Threads as Postgres Rows, With No Queue Server

Part of the Determesh series. What Every conversation in Determesh, and every piece of work behind it, is a thread. A thread is a row in Postgres with a status. Workers claim runnable rows with SELECT ... FOR UPDATE SKIP LOCKED, run them, and write the result back. There is no message broker and no workflow engine. Postgres is the queue and the record at once. Why The design was already a queue of records The design said threads are loosely tied. A thread waiting on a manager’s approval holds nothing: no process, no timer, no connection. If the manager replies in five years, the thread picks up. A new message from the user reopens a thread that finished. A parent waits for its children, and children can wait for each other. ...

October 25, 2026 · 5 min · 1008 words · Sagar Nayak

Branch the Session Instead of Narrowing It

Part of the Refresh Token Design series. The Question the Last Post Left Open A refresh arrives carrying a device proof that does not verify. Two things can produce it, and the request looks identical either way. A browser that lost its key and generated a new one, which is ordinary and frequent. Somebody holding a copy of the refresh token, who cannot sign because the key never left the machine it was made on. ...

July 26, 2026 · 6 min · 1198 words · Sagar Nayak

Refresh Token Rotation With a Previous Pair

Part of the Refresh Token Design series. The Problem With Single Use Single use refresh tokens are the standard advice and the advice is right. A refresh token that works twice is a refresh token somebody can steal and use behind you. The trouble is the failure mode when a response goes missing. A client sends its refresh token. The server rotates, writes the new pair, and answers. The answer never arrives, because the tunnel dropped, the phone changed cell, the laptop lid closed. The client still holds the old token, and the old token is now spent. It retries, gets refused, and the person is looking at a login screen because of one lost packet. ...

June 28, 2026 · 7 min · 1406 words · Sagar Nayak

Migrating n8n from SQLite to PostgreSQL

What The n8n instance on our production server stopped processing work. One workflow, a telemetry collector that receives a stream of concurrent webhook calls, had overloaded the database and taken the whole instance down with it. The numbers when we looked: 300+ executions stuck in running state 346 executions in new state that never started 161 executions failed with LockAcquireTimeoutError The UI was slow enough to be unusable The error behind all of it: ...

June 8, 2026 · 5 min · 985 words · Sagar Nayak

Friday Snapshots: Weekly Portfolio and Historical Backfill

Part of the Sanchayam series. Why Friday Portfolio performance is tracked week by week, not day by day. Daily snapshots would generate a large amount of data for a view that is displayed weekly at best. Friday is chosen because Indian markets close at 3:30 PM IST on Friday. The snapshot cron runs at 11:00 AM UTC, which is 4:30 PM IST - 30 minutes after market close, giving price feeds time to settle. ...

May 14, 2026 · 4 min · 811 words · Sagar Nayak