Skip to content

Conversation

ffuugoo
Copy link
Contributor

@ffuugoo ffuugoo commented Jul 7, 2025

Follow-up to #6778.

After #6778, we initialize custom shard replicas in Initializing state, and so when Qdrant returns response to the client, it does not yet guarantee that custom shard is ready to accept write requests. There will be a small delay while shards switch from Initializing into Active state and fully available.

This PR adds explicit wait_for_state check, so that we ensure all replicas are Active before returning response to the client. I've also very slightly tweaked test_shard_consistency test, so that it should cover this check as part of existing test.

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@ffuugoo ffuugoo force-pushed the custom-shard-await-active branch from 8db9214 to c105990 Compare July 7, 2025 13:43
ffuugoo added 2 commits July 7, 2025 15:47
- so that it creates custom shards in `Initializing` state instead of
  `Active`
- and in doing so, also covers the check that `create_shard_key` request
  waits for replica activation
@ffuugoo ffuugoo marked this pull request as ready for review July 7, 2025 14:01
@ffuugoo ffuugoo requested review from timvisee and generall July 7, 2025 14:01

This comment was marked as resolved.

&self,
check: F,
timeout: Duration,
) -> impl Future<Output = CollectionResult<()>> + 'static
Copy link
Member

Choose a reason for hiding this comment

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

What was a reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this change, wait_for was borrowing/lifetime-bound to ReplicaSet, so you had to hold a lock to ReplicaSet while await-ing wait_for.

With this change, wait_for creates a future that is completely independent of ReplicaSet, so that you can call wait_for, release the lock to ReplicaSet, and then await wait_for future.

if status {
Ok(())
} else {
Err(CollectionError::service_error(
Copy link
Member

Choose a reason for hiding this comment

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

I checked usages, it should be safe to convert this error to timeout. Both Service Error and timeout are transient, also it looks like all actual places where it is used either don't care or force convert error into service error.

Comment on lines +303 to +306
for replica_set in shard_holder.all_shards() {
if replica_set.shard_key() != Some(&shard_key) {
continue;
}
Copy link
Member

Choose a reason for hiding this comment

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

Shall we create a getter in the shard holder to which we pass the key? That way we keep the shard key selection logic inside the shard holder.

We have some methods related to shard keys there, to get the shard IDs related to a shard key for example. But for this we'd probably require a new one.

@ffuugoo ffuugoo merged commit 68a6536 into dev Jul 8, 2025
18 checks passed
@ffuugoo ffuugoo deleted the custom-shard-await-active branch July 8, 2025 10:18
generall added a commit that referenced this pull request Jul 17, 2025
Co-authored-by: generall <andrey@vasnetsov.com>
Co-authored-by: timvisee <tim@visee.me>
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.

3 participants