github nenadjokic/navibeat-mixes v0.9.9

latest releases: v0.9.11, v0.9.10
9 days ago

0.9.9: the nightly run finishes on a slow server

Found on a live server (Navidrome 0.63.2 on a NAS under heavy load): no mix had been written for a week. Navidrome stops any plugin call after 30 seconds, and the candidate pool alone, about 300 Subsonic calls per account, took longer than that, so every 04:00 run was killed before its first playlist write. The 20 second budget from 0.9.1 never got a chance to trip because it was only checked between writes, after the pool.

Three more things went wrong around it: the continuation could not schedule its own successor ("schedule ID navibeat-mixes-continue already exists"), because Navidrome keeps a one-time schedule registered until its callback has returned; the first generation ran inside OnInit and was killed the same way; and a slow step could start with less time left than it needed.

What changed

  • The budget is checked after every Subsonic page, not only between playlist writes. A half-built pool is parked in the plugin's key-value store, gzipped (about 27 bytes per track), and the next call carries on from that page instead of starting over. A finished pool is parked too, so a continuation that only has playlists left to write does not refetch it.
  • Each call measures its steps and stops as soon as the time left is shorter than the last step took. The default budget is 15 seconds; a new budgetSeconds setting (3 to 25) in the Tuning group changes it.
  • Continuations are numbered (navibeat-mixes-continue-1, -2, ...), the previous one is cancelled before the next is scheduled, and a stale one is forgotten when the plugin loads. A chain of any length works now.
  • A plugin load schedules the first generation ten seconds out instead of running it inline, so loading can no longer hit the deadline.
  • A chain that makes progress is never cut, however many calls it takes; an account that gets no further three calls in a row is given up for the day, and the log says so once.
  • The log says what happened at every hand-over: budget, elapsed time, steps, the length of the last step, and the id of the continuation.

Every existing mix keeps its name and slot. Measured end to end on a throwaway Navidrome 0.63.2: with a three second budget a run parked its pool at 3.4 seconds, resumed and completed it in the second call, and wrote all 23 mixes in the third. Fourteen new unit tests cover the budget, the continuation chain against a fake of Navidrome's scheduler, and the parked pool.

Permissions are unchanged from 0.9.8.

Don't miss a new navibeat-mixes release

NewReleases is sending notifications on new releases.