Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate metastore to code generated metastore service #3898

Merged
merged 4 commits into from
Oct 21, 2023

Conversation

fmassot
Copy link
Contributor

@fmassot fmassot commented Sep 30, 2023

TODO

  • Readd ability to get index metadata by IndexUid
  • Instrument metastore with a tower layer
  • Readd check_connectivity and uris methods (add a new trait MetastoreServiceExt?)
  • Readd index_exists method
  • When testing, it's easy to MetastoreServiceClient::new(mock_metastore), but we need to wrap the mock. Also it's possible to do MockMetastoreService::new() and I think we don't want a developer to do that => I added an assert if a dev instantiate with MetastoreServiceClient::new instead of MetastoreServiceClient::from.
  • Some proto requests have a default implementation that will generate an empty json payload, this is bad The solution would be to have only optional fields....
  • Simplify the building of some gRPC requests.
  • Simplify how metrics are added to gRPC requests
  • Clean code
  • Check how proto files are generated and see how to avoid repetition of ".type_attribute("Shard", "#[derive(Eq)]")"
  • make test-all
  • test local cluster with 3 nodes and check create index - ingest - delete index works.

Next steps:

  • Put the metastore documentation in the internal docs
  • Replace the control plane metastore implementation by a proxy layer. The annoying part is that we would need to implement each Service<R> for each metastore request on the control plane client. I don't have a concrete plan on this and prefer to open an issue to fix it later. I may miss an obvious solution, let's discuss that tomorrow.
  • Open an issue to refactor the metastore factory cache.
  • Replace ListSplitsRequest::try_from_index_uid by ListSplitsRequest::from_index_uid as we are sure this builder won't fail.

@fmassot fmassot changed the title Migrate to code generated metastore service - WIP Migrate metastore to code generated metastore service - WIP Sep 30, 2023
@fmassot fmassot force-pushed the fmassot/migrate-codegen-metastore branch 2 times, most recently from a4d7a3e to baebca5 Compare October 1, 2023 22:24
@fmassot fmassot force-pushed the fmassot/migrate-codegen-metastore branch 10 times, most recently from c665a7f to 1e66102 Compare October 16, 2023 13:06
@fmassot fmassot force-pushed the fmassot/migrate-codegen-metastore branch 6 times, most recently from ee70464 to ca832cc Compare October 18, 2023 21:14
@fmassot fmassot marked this pull request as ready for review October 18, 2023 21:24
@fmassot fmassot force-pushed the fmassot/migrate-codegen-metastore branch from ca832cc to 148460a Compare October 18, 2023 22:20
@fmassot fmassot changed the title Migrate metastore to code generated metastore service - WIP Migrate metastore to code generated metastore service Oct 18, 2023
@fmassot fmassot requested a review from guilload October 18, 2023 22:28
quickwit/quickwit-cli/src/tool.rs Outdated Show resolved Hide resolved
quickwit/quickwit-proto/protos/quickwit/metastore.proto Outdated Show resolved Hide resolved
quickwit/quickwit-proto/protos/quickwit/metastore.proto Outdated Show resolved Hide resolved
quickwit/quickwit-cli/tests/cli.rs Outdated Show resolved Hide resolved
quickwit/quickwit-codegen/Cargo.toml Show resolved Hide resolved
.await;
let delete_splits_request = DeleteSplitsRequest {
index_uid: index_uid.to_string(),
split_ids: split_ids.clone(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need to clone?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the error message, is that what you mean?
I'm fine with removing it, we return the appropriate metastore error that we could log instead.

quickwit/quickwit-index-management/src/index.rs Outdated Show resolved Hide resolved
@fmassot fmassot force-pushed the fmassot/migrate-codegen-metastore branch 3 times, most recently from 77c80df to 89e8c1a Compare October 20, 2023 20:03
quickwit/quickwit-indexing/src/actors/publisher.rs Outdated Show resolved Hide resolved
quickwit/quickwit-indexing/src/source/mod.rs Outdated Show resolved Hide resolved
cache: Arc<Mutex<HashMap<Uri, Weak<dyn Metastore>>>>,
// We never garbage collect unused metastore client instances. This should not be a problem
// because during normal use this cache will hold at most a single instance.
cache: Arc<Mutex<HashMap<Uri, MetastoreServiceClient>>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is true, maybe we should use an Arc<Mutex<Option<(Uri, MetastoreServiceClient)>>> and always evict the old client if URIs don't match (and log a warning?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea and I tested it. Only a few tests are failing if we changed this. We need to also to refactor the factory as now the code between the file backed factory cache and the postgres factory cache is exactly the same.

quickwit/quickwit-metastore/src/metastore/mod.rs Outdated Show resolved Hide resolved
storage_resolver: &StorageResolver,
index_id: &str,
source_config_opt: Option<&SourceConfig>,
) -> anyhow::Result<()> {
let mut checks: Vec<(&str, anyhow::Result<()>)> = Vec::new();

// The metastore is file-backed, so we must check the storage first.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is useless. The check connectivity of the metastore will do the right check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave it. The checklist will tell you it's a metastore issue, whereas it stems from the storage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will change the comment then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to do the right check in the metastore method and make sure the error displayed is clean.

@fmassot fmassot force-pushed the fmassot/migrate-codegen-metastore branch from 0f530a6 to 4c43b9b Compare October 21, 2023 15:12
@fmassot fmassot force-pushed the fmassot/migrate-codegen-metastore branch from dc1abe3 to 7655fb0 Compare October 21, 2023 16:29
@fmassot fmassot merged commit 4d83afd into main Oct 21, 2023
@fmassot fmassot deleted the fmassot/migrate-codegen-metastore branch October 21, 2023 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants