-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
our storage classes are hella confusing #11733
Comments
Would the (new) naming be worth documenting? (Even though its considered developer use only?) |
If anyone is going to spend effort on this, I'd rather it be spent on changing the source code |
The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
Do we know of anyone making use of this? |
No. At one point we thought we might use it on |
Discussed today: One suggestion was |
further ideas:
further ideas:
|
Right, here are my proposals for the least bad names for these things. Speak now or forever hold your peace:
🚀 for "this is the best naming convention ever" |
Does the name How do |
I'm okay with the proposal. I agree that |
No, it's more of an abstract concept: "the storage system".
I've tried to explain this in the opening comment; in short, a
Yeah, great question. The distinction is very woolly, which maybe suggests this architecture isn't great. In my head, a .oO (hrm, |
I've implemented this at #12913 TBH, to me this doesn't feel like its made anything clearer (beyond making |
Related: #11165 (I semiregularly try to find that issue by searching for |
Store
,StateGroupDataStore
,DataStore
,Storage
,DatabasePool
,Databases
... 🤯#8033 made some attempts to clean it up, but there's a lot more to do here.
There are basically three layers:
a
DatabasePool
represents a connection to a physical database. Normally you have exactly one of these, but it's possible to set Synapse up to talk to two separate postgres instances (one of them gets used for state storage (state_groups_state
, mainly), and the other for everything else), in which case you have two.a
<foo>Store
is a low-level thing containing SQL, and is linked to a singleDatabasePool
. We basically have two of these (state
andmain
), again with the state/everything else split.state
is always aStateGroupDataStore
, butmain
can be any of (DataStore
,AdminCmdSlavedStore
,GenericWorkerSlavedStore
) depending on the synapse app.PersistEventsStore
seems to be a special case, and is a layer over themain
store.Databases
is a singleton which instantiates theDatabasePool
s and<foo>Stores
, and holds references to them.a
<foo>Storage
is a higher-level thing which spans multiple<foo>Stores
. Ideally it does not do any SQL itself, but delegates it all to theStore
s. We have three of these (PurgeEventsStorage
,StateGroupStorage
,EventsPersistenceStorage
). Note that a lot of non-storage code skips this layer and goes straight to the<foo>Store
s.Storage
itself instantiates and holds references to the<foo>Storage
s.Edit 2022/06/06: These are now known as
<foo>StorageController
s, andStorage
itself is now known asStorageControllers
.This is all very well, but I seem to be incapable of holding it in my head at once. This is really not helped by there being a lot of inconsistent naming. Examples:
Databases
should surely be calledDataStoreManager
or similar. AndHomeServer.get_datastores
, which returns theDatabases
, should be renamed.Storage
->StorageManager
. (superceded by Rename storage classes #12913)Store
could do with being named as such, for consistency withStateGroupDataStore
- egMasterMainDataStore
,WorkerMainDataStore
.HomeServer.get_datastore
(which returns the mainStore
) exists only for backwards compatibility. We should replace it with calls toget_datastores().main
for consistency with theStateGroupDataStore
. RemoveHomeServer.get_datastore()
#12031self.store
should instead have aself._main_store
.The text was updated successfully, but these errors were encountered: