L2-Technology/sensei

Add support for Postgres

Closed this issue · 8 comments

Currently Sensei uses SQLite as its main datastore. It would be great so support more production-grade databases as well for larger deployments. Without digging very far into the code, I don't think this would be a major lift given it's already leveraging a relational database.

I'm imagining this could be a configuration option on startup to choose your database.

Yeah, I want to do this as well. Should be pretty easy to implement this. I guess each child node could still have it's own database within the same postgres instance similar to how it's currently structured with sqlite.

I think that could work. Given the max database limit in Postgres is 4,294,950,911. Seems pretty scalable and good to separate them.

https://www.postgresql.org/docs/12/limits.html

Yeah, would make it possible to actually use separate postgres instance per child node as well...should a need for that ever arise.

I can take a stab at this.

this probably requires more thought but the nodes do save state to the filesystem outside of the sqlite database. currently it's using the default ldk persistence layer for channel state. i feel like it might be a good goal to remove reliance on the filesystem entirely? thoughts?

Yeah 100% agree. I think the less that's on the filesystem (outside the database) the better.

Just realized we will need to implement Postgres for bdk::database::Database. Should be pretty straight forward once there is a good Postgres example

Actually I'm thinking after the 'generic database layer' work lands we will likely want to just combine the bdk database with the sensei database and implement bdk::database::Database for this generic layer. This way there's just a single database for all the data.