Conversation
92d0c97 to
d26f101
Compare
d26f101 to
7cf6268
Compare
|
what's MetaStore? |
Storage for metadata (aka namespace configs) |
d86cc92 to
1e9ec0b
Compare
| store: Namespace<T>, | ||
| } | ||
|
|
||
| async fn execute<B: QueryResultBuilder>( |
There was a problem hiding this comment.
These next few functions I would like to refactor into a proper struct but for now this will do. Marked as follow up item 👍
| let sender = lock.entry(namespace.clone()).or_insert_with(|| { | ||
| // TODO(lucio): if no entry exists we need to ensure we send the update to | ||
| // the bg channel. | ||
| let (tx, _) = watch::channel(Arc::new(DatabaseConfig::default())); |
There was a problem hiding this comment.
There is a follow up item for this in #768
| @@ -0,0 +1 @@ | |||
|
|
|||
There was a problem hiding this comment.
reserved for some tests that I will do as follow up but this will require getting bottomless backups also working in our test suite which may be a lot of work.
There was a problem hiding this comment.
I think this will create more confusion than value. I don't think anyone will still the meta.rs file so I would just drop this from the PR
There was a problem hiding this comment.
I've added a test here, these will be expanded upon in follow up PRs
5ebc56a to
c0d349d
Compare
|
As discussed in our call, I don't think this is the right approach. Instead, I propose that we do the following:
Configuration changes regarding a replica are propagated by mean of the replication protocol. The primary sends the relevant configuration to the replica in the handshake response. When the config for a replica changes, the primary requests a new handshake, and the replica updates its config. |
@LucioFranco please make sure you split that work into two parts: on instance storage + primary/replica synchronization. The first part is blocking the per namespace jwts so it would be great to get it done quick. |
c9ffaad to
a545db6
Compare
a545db6 to
6668911
Compare
Added a TODO to #768 @MarinPostma and I have a good idea how to do this and yes we can merge this now and unblock your work. |
6668911 to
fdcb4a8
Compare
|
@haaawk @MarinPostma this is ready for review and I've added a test as well. |
fdcb4a8 to
fce0516
Compare
|
|
||
| let rows = stmt.query(())?.mapped(|r| { | ||
| let ns = r.get::<_, String>(0)?; | ||
| let config = r.get::<_, Vec<u8>>(1)?; |
There was a problem hiding this comment.
There's no need to allocate here, you can get a &[u8] and parse json straight from it
There was a problem hiding this comment.
I tried to change this to a borrowed version but since the row borrow is only for this closure we can't return it. I think since this is just a restore a string/vec is fine here, we can change if we find its really causing issues. Configs should be quite small anyways.
| Internal(Arc<Mutex<Arc<DatabaseConfig>>>), | ||
| External(mpsc::Sender<ChangeMsg>, Receiver<Arc<DatabaseConfig>>), |
There was a problem hiding this comment.
what's the purpose of those?
There was a problem hiding this comment.
Some unit tests use the internal so its a legacy thing that we can eventually remove but it was done in place to allow those tests to not have to update how they work with the metastore.
| // when we are updating the config. The config si already synced via the watch | ||
| // channel. | ||
| configs: HashMap<NamespaceName, Sender<Arc<DatabaseConfig>>>, | ||
| db: Connection, |
There was a problem hiding this comment.
you should use a libsql_sys::Connection here instead
There was a problem hiding this comment.
Also, I get it that you want to add durability in a subsequent PR?
There was a problem hiding this comment.
Added as follow up item in #768 (related to bottomless backup).
|
I left a few comments; feel free to dismiss, merge, and address them in a follow-up. |
|
|
||
| #[derive(Debug, Clone)] | ||
| enum HandleState { | ||
| Internal(Arc<Mutex<Arc<DatabaseConfig>>>), |
There was a problem hiding this comment.
Could we have Arc<Mutex<DatabaseConfig>>?
There was a problem hiding this comment.
Returned type expects an Arc<DatabaseConfig> so we unfortunately need to do this but that said this code should be test only and internal unit test so let me see if I can wrap in a cfg and we can forget about it until we refactor those tests.
|
|
||
| let mut configs = HashMap::new(); | ||
|
|
||
| for row in rows { |
There was a problem hiding this comment.
Why two loops instead of looping over query results and do what this loop is doing straight away?
There was a problem hiding this comment.
Conceptually and api wise, 1) being I like having the part that extracts out of the row be its own piece of code (but we rows doesn't implement iterator so we can't just loop) and 2) then putting the actual de serialization where we want some special logic in a separate block. Goal being that people should focus on the big for loop rather than the mapped rows section.
This PR adds a new internal metadata store for namespace configuration. This internally uses a normal namespace so that the replica also get's synchronized. This is just initial work there are a few more issues to solve regarding replica's getting updated configs and some internal hardening that needs to be done. Tracking issue for follow up work #768. Closes #501
fce0516 to
b1da52c
Compare
This PR adds a new internal metadata store for namespace configuration.
This internally uses a normal namespace so that the replica also get's
synchronized. This is just initial work there are a few more issues to
solve regarding replica's getting updated configs and some internal
hardening that needs to be done. Tracking issue for follow up work #768.
Closes #501