clockworklabs / SpacetimeDB

Multiplayer at the speed of light
https://spacetimedb.com
Other
4.12k stars 100 forks source link

core: Collapse DBIC into HostController #1186

Open kim opened 2 weeks ago

kim commented 2 weeks ago

Make it so HostController manages both the module host (wasm machinery) and the database (RelationalDB / DatabaseInstanceContext) of spacetime databases deployed to a server.

The DatabaseInstanceContextController (DBIC) is removed in the process.

This allows to make database accesses panic-safe, in that uncaught panics will cause all resouces to be released and the database to be restarted on subsequent access. This is a prerequisite for #985.

It also allows to move towards storage of the module binary directly in the database / commitlog. This patch, however, makes some contortions in order to not introduce a breaking change just yet.

Expected complexity level and risk

2.5

Testing

kim commented 2 weeks ago

Please feel free to suggest naming / terminology changes. I felt uninspired so stuck with ecru.

kim commented 2 weeks ago

Also, I am unsure if we tracked energy in standalone before, or if I introduced it accidentally.

kim commented 2 weeks ago

@kazimuth @RReverser It is somewhat mysterious to me how the repeated StandaloneEnv::init with same database directory could possibly work. Is there something I'm missing, or was it just incidental that it worked?

kim commented 2 weeks ago

In both cases, the database was inaccessible after the panic.

That sounds wrong, it should come up again (lazily). Will investigate…

Thanks for testing!

gefjon commented 2 weeks ago

In both cases, the database was inaccessible after the panic.

That sounds wrong, it should come up again (lazily). Will investigate…

Disregard. It does in fact seem to come up again, I was just mistaking my quickstart-chat being unable to connect due to stale credentials.