Bluesky migrates to single-tenant SQLite

The PDS has undergone a significant refactoring, now utilizing a single-tenant SQLite datastore. This means that each user has their own SQLite file to store both their repository and private account state. These user databases are organized hierarchically for easy management. Additionally, repo signing keys are now stored alongside the SQLite file.

To interact with user data, we have implemented the ActorStore, which allows for clear transactional writes due to SQLite’s lack of support for concurrent transactions. The ActorStore also includes an LRUCache, which can hold up to 30k open file handles and keys in memory. When a database is removed from the cache, its file handle is properly closed.

Furthermore, we have introduced three separate SQLite databases to manage service state. These include a service database for account information, invite codes, and refresh tokens, a did cache database for caching DID resolutions, and a sequencer database for sequencing repo updates.

To enable concurrent reads and streaming replication, all of these SQLite files are run in Write-Ahead Log (WAL) mode. In the future, we plan to ship the PDS distribution with Litestream or a similar tool.

https://github.com/bluesky-social/atproto/pull/1705

To top