SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Views: cleanup unsubscribed views

Open Shubham8287 opened this issue 1 month ago • 1 comments

Description of Changes

A tokio task to cleanup unsubscribed views. fixes #3587

API and ABI breaking changes

NA

Expected complexity level and risk

2

Testing

Added a test

Shubham8287 avatar Nov 12 '25 20:11 Shubham8287

Test is better modularised in this PR - https://github.com/clockworklabs/SpacetimeDB/pull/3670.

Shubham8287 avatar Nov 17 '25 19:11 Shubham8287

  1. Also we probably want to bound the length of time a cleanup job takes. If there are many old views, I think we'd rather clean them up in multiple jobs to avoid taking a tx lock for an extended period of time.

Should it be limited by a hardcoded number (like 100 cleanups at a time) Or duration (atmost to take 5ms) or something else?

I feel limiting it to hardcoded number of views to cleanup can be a problem if continously more new views expires more than that number between job intervals.

Shubham8287 avatar Nov 20 '25 06:11 Shubham8287

I agree, I think duration is the right metric. And we can even make that duration configurable later (not a requirement for this PR).

joshua-spacetime avatar Nov 20 '25 06:11 joshua-spacetime