somratpro Claude Haiku 4.5 commited on
Commit
e77bcc1
·
1 Parent(s): 4a30806

Purge orphaned heartbeat run UUID from all tables before launch

Browse files

The orphaned run 1fc2bf0e... triggers Paperclip's startup recovery
which overflows the stack via firstBlockedChainFinding. Even when
caught, downstream periodic checks crash Paperclip. Solution:
delete the UUID from every UUID column across every public table
before launch, so recovery has nothing to do.

Foreign-key constraint failures are swallowed per-row.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. start.sh +31 -0
start.sh CHANGED
@@ -212,6 +212,37 @@ cleanup() {
212
  }
213
  trap cleanup SIGTERM SIGINT
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  # ── Launch Paperclip ──────────────────────────────────────────────────────────
216
  echo "Starting Paperclip..."
217
  node --unhandled-rejections=none --import ./server/node_modules/tsx/dist/loader.mjs server/dist/index.js &
 
212
  }
213
  trap cleanup SIGTERM SIGINT
214
 
215
+ # ── Purge orphaned heartbeat run that triggers recovery stack overflow ───────
216
+ ORPHAN_RUN_ID="1fc2bf0e-f983-4ec7-b941-2df338d53ab4"
217
+ echo "Purging orphaned run ${ORPHAN_RUN_ID} from all UUID columns..."
218
+ su - postgres -c "psql paperclip" <<SQLEOF >/dev/null 2>&1 || true
219
+ \echo 'Heartbeat/run tables:'
220
+ SELECT tablename FROM pg_tables
221
+ WHERE schemaname='public'
222
+ AND (tablename LIKE '%heartbeat%' OR tablename LIKE '%run%');
223
+
224
+ DO \$\$
225
+ DECLARE
226
+ rec RECORD;
227
+ rid uuid := '${ORPHAN_RUN_ID}';
228
+ BEGIN
229
+ FOR rec IN
230
+ SELECT n.nspname AS s, t.relname AS tn, a.attname AS cn
231
+ FROM pg_attribute a
232
+ JOIN pg_class t ON a.attrelid = t.oid
233
+ JOIN pg_namespace n ON t.relnamespace = n.oid
234
+ JOIN pg_type ty ON a.atttypid = ty.oid
235
+ WHERE n.nspname='public' AND t.relkind='r'
236
+ AND ty.typname='uuid' AND NOT a.attisdropped
237
+ LOOP
238
+ BEGIN
239
+ EXECUTE format('DELETE FROM %I.%I WHERE %I = \$1', rec.s, rec.tn, rec.cn) USING rid;
240
+ EXCEPTION WHEN OTHERS THEN NULL;
241
+ END;
242
+ END LOOP;
243
+ END \$\$;
244
+ SQLEOF
245
+
246
  # ── Launch Paperclip ──────────────────────────────────────────────────────────
247
  echo "Starting Paperclip..."
248
  node --unhandled-rejections=none --import ./server/node_modules/tsx/dist/loader.mjs server/dist/index.js &