[GH-ISSUE #4630] [Issue]: Noodler reserve reconciler full-scans noodle tables every 60s even when automatic posting is disabled #2530

Closed
opened 2026-10-21 05:49:36 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Aug 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4630

Originally assigned to: @Gunterlie on GitHub.

Summary

The Noodler reserve scheduler full-scans the noodlerPreparedPosts and noodlePosts tables (with per-row JSON parsing), plus re-lists prepared posts and both account tables, every 60 seconds, forever, even when Noodler/automatic posting is disabled and the tables are empty. On the file-native store these are full table materializations — a permanent idle CPU tick that matters most on phone/Termux installs.

Expected behavior

The periodic reconcile tick early-exits (or backs off) when automatic posting is disabled and there is no reserve state to reconcile. (The startup reconcile is intentionally unconditional — the scheduler comment explains upgrades must begin their hold even when posting is disabled — and should stay.)

Actual behavior

  • startNoodleAutoPostScheduler (packages/server/src/services/noodle/noodle-autopost-scheduler.service.ts:28-78) arms a 60 s poll from 30 s after boot. poll() calls reconcileNoodlerReserve(app.db) (line 50) before any enabled/settings check — the only gate is the backup-pause (pauseDepth).
  • reconcileNoodlerReserve → reconcileNoodlerPreparedPosts (packages/server/src/services/storage/noodle.storage.ts:2018-2068): loads settings at line 2019 but does not consult them before scanning — it opens a transaction and runs tx.select().from(noodlerPreparedPosts) + tx.select().from(noodlePosts) (lines 2021-2024), then parseRecord(post.metadata) (JSON.parse) for every post row (line 2027). After the transaction it does a second round of full reads: listNoodlerPreparedPosts() + listAccounts() + listNoodlerAccounts() (lines 2065-2068).
  • Then publishDueNoodlerPreparedPosts (line 1900) runs as well.

Every 60 seconds, with zero connected clients, feature disabled, and nothing to reconcile. On an active Noodle install (many noodlePosts rows) each tick JSON-parses every post's metadata — on the file-native store there is no index, so this is O(all posts) per minute for the server's lifetime.

Steps to reproduce

  1. Run the server with Noodler/automatic posting disabled (default).
  2. Set a breakpoint / add a debug log in reconcileNoodlerPreparedPosts.
  3. Observe the full-table selects firing every 60 s indefinitely with no clients connected.

Environment

  • Marinara Engine version: 2.4.2 (staging, 93738d9b1)
  • Install type: source; battery-relevant on Termux (server on phone)
  • OS + version: any (verified by code trace on staging)
  • Browser or app shell: N/A (server-side)

Logs, screenshots, or video

Code trace above (line references verified against current staging).

Additional context

Found during a mobile-battery investigation (two user reports: browser-client heat + Termux baseline drain). Related sibling pattern worth a look in the same pass: the Noodle timeline-refresh scheduler also wakes every 60 s when refreshesPerDay === 0 instead of backing off.

Suggested fix: in the periodic poll() (not the startup pass), check settings first and early-exit when automatic posting is disabled and a cheap count of noodlerPreparedPosts is zero; alternatively back the poll off (e.g. 15 min) while disabled. The startup reconcile keeps its current unconditional behavior per the scheduler's own comment.

Filed alongside #4628 (assistant streaming) and #4629 (extension runtime polling).

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Aug 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4630 Originally assigned to: @Gunterlie on GitHub. ## Summary The Noodler reserve scheduler full-scans the `noodlerPreparedPosts` **and** `noodlePosts` tables (with per-row JSON parsing), plus re-lists prepared posts and both account tables, **every 60 seconds, forever, even when Noodler/automatic posting is disabled and the tables are empty**. On the file-native store these are full table materializations — a permanent idle CPU tick that matters most on phone/Termux installs. ## Expected behavior The periodic reconcile tick early-exits (or backs off) when automatic posting is disabled and there is no reserve state to reconcile. (The **startup** reconcile is intentionally unconditional — the scheduler comment explains upgrades must begin their hold even when posting is disabled — and should stay.) ## Actual behavior - `startNoodleAutoPostScheduler` (`packages/server/src/services/noodle/noodle-autopost-scheduler.service.ts:28-78`) arms a 60 s poll from 30 s after boot. `poll()` calls `reconcileNoodlerReserve(app.db)` (line 50) **before any enabled/settings check** — the only gate is the backup-pause (`pauseDepth`). - `reconcileNoodlerReserve` → `reconcileNoodlerPreparedPosts` (`packages/server/src/services/storage/noodle.storage.ts:2018-2068`): loads settings at line 2019 but **does not consult them before scanning** — it opens a transaction and runs `tx.select().from(noodlerPreparedPosts)` + `tx.select().from(noodlePosts)` (lines 2021-2024), then `parseRecord(post.metadata)` (JSON.parse) for **every post row** (line 2027). After the transaction it does a second round of full reads: `listNoodlerPreparedPosts()` + `listAccounts()` + `listNoodlerAccounts()` (lines 2065-2068). - Then `publishDueNoodlerPreparedPosts` (line 1900) runs as well. Every 60 seconds, with zero connected clients, feature disabled, and nothing to reconcile. On an active Noodle install (many `noodlePosts` rows) each tick JSON-parses every post's metadata — on the file-native store there is no index, so this is O(all posts) per minute for the server's lifetime. ## Steps to reproduce 1. Run the server with Noodler/automatic posting disabled (default). 2. Set a breakpoint / add a debug log in `reconcileNoodlerPreparedPosts`. 3. Observe the full-table selects firing every 60 s indefinitely with no clients connected. ## Environment - Marinara Engine version: 2.4.2 (staging, 93738d9b1) - Install type: source; battery-relevant on Termux (server on phone) - OS + version: any (verified by code trace on staging) - Browser or app shell: N/A (server-side) ## Logs, screenshots, or video Code trace above (line references verified against current staging). ## Additional context Found during a mobile-battery investigation (two user reports: browser-client heat + Termux baseline drain). Related sibling pattern worth a look in the same pass: the Noodle timeline-refresh scheduler also wakes every 60 s when `refreshesPerDay === 0` instead of backing off. Suggested fix: in the periodic `poll()` (not the startup pass), check settings first and early-exit when automatic posting is disabled **and** a cheap count of `noodlerPreparedPosts` is zero; alternatively back the poll off (e.g. 15 min) while disabled. The startup reconcile keeps its current unconditional behavior per the scheduler's own comment. Filed alongside #4628 (assistant streaming) and #4629 (extension runtime polling). ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:49:36 +07:00
Author
Owner

@Gunterlie commented on GitHub (Aug 5, 2026):

Picked this up — draft PR #4635 (branch noodler-for-the-cpu-poor) covers both the reserve poll early-exit and the disabled timeline-refresh backoff. Owner: @Gunterlie.

<!-- gh-comment-id:5192958561 --> @Gunterlie commented on GitHub (Aug 5, 2026): Picked this up — draft PR #4635 (branch `noodler-for-the-cpu-poor`) covers both the reserve poll early-exit and the disabled timeline-refresh backoff. Owner: @Gunterlie.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2530
No description provided.