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

Divergence of the number of shards in the metastore vs as seen from the control plane #5008

Closed
fulmicoton opened this issue May 21, 2024 · 4 comments · Fixed by #5029
Closed
Labels
bug Something isn't working

Comments

@fulmicoton
Copy link
Contributor

fulmicoton commented May 21, 2024

As observed on airmail

select count (*) AS shards from shards;
 shards 
--------
 763471
(1 row)

While the control plane sees a much lower shard count (~3000s)

@fulmicoton fulmicoton added the bug Something isn't working label May 21, 2024
@fulmicoton
Copy link
Contributor Author

This is probably not the cause, but this causes a divergence between metastore and CP

        if let Err(control_plane_error) = self
            .auto_create_indexes(&request.subrequests, ctx.progress())
            .await
        {
            return Ok(Err(control_plane_error));
        }

@fulmicoton
Copy link
Contributor Author

I suspect the problem is that we

- open shard on metastore
- init shard on ingest
- only update the model for successfully initialized shards

So if an ingester happens to be unreachable etc., we end up with some dangling shard in the metastore.

@fulmicoton
Copy link
Contributor Author

scale_up shards seems buggy too.

   let open_shards_response = match progress
            .protect_future(self.metastore.open_shards(open_shards_request))
            .await
        {
            Ok(open_shards_response) => open_shards_response,
            Err(error) => {
                warn!("failed to scale up number of shards: {error}");
                model.release_scaling_permits(&source_uid, ScalingMode::Up, NUM_PERMITS);
                return;
            }
        };

fulmicoton added a commit that referenced this issue May 21, 2024
@fulmicoton
Copy link
Contributor Author

Split into #5013 #5014 #5020

fulmicoton added a commit that referenced this issue May 26, 2024
On scale up, rebalance, and get_or_open_shards, the control plane was:
- recording a shard on the metastore
- writing the shard
- record the shard on the control plane model.

Error handling was not done, so a transport failure on the metastore, or
(more likely) an error failure on init would break consistency between
the metastore and the control plane.

This PR factorizes the idea of opening a new shard for scale up,
rebalance and get_or_open_shards.

The new factorize logic goes:
- init first
- record in the metastore
- record the shard on the control plane model.

The last two steps are also factorized together to emphasize that we
keep the control plane and metastore in sync.

It works by forcing a restart of the control plane if the metastore
returns an error for which we don't know if the write was a success or
not.

Closes #5008
Closes #5020
Closes #5013

test compilation
fulmicoton added a commit that referenced this issue May 26, 2024
On scale up, rebalance, and get_or_open_shards, the control plane was:
- recording a shard on the metastore
- writing the shard
- record the shard on the control plane model.

Error handling was not done, so a transport failure on the metastore, or
(more likely) an error failure on init would break consistency between
the metastore and the control plane.

This PR factorizes the idea of opening a new shard for scale up,
rebalance and get_or_open_shards.

The new factorize logic goes:
- init first
- record in the metastore
- record the shard on the control plane model.

The last two steps are also factorized together to emphasize that we
keep the control plane and metastore in sync.

It works by forcing a restart of the control plane if the metastore
returns an error for which we don't know if the write was a success or
not.

Closes #5008
Closes #5020
Closes #5013
fulmicoton added a commit that referenced this issue May 26, 2024
On scale up, rebalance, and get_or_open_shards, the control plane was:
- recording a shard on the metastore
- writing the shard
- record the shard on the control plane model.

Error handling was not done, so a transport failure on the metastore, or
(more likely) an error failure on init would break consistency between
the metastore and the control plane.

This PR factorizes the idea of opening a new shard for scale up,
rebalance and get_or_open_shards.

The new factorize logic goes:
- init first
- record in the metastore
- record the shard on the control plane model.

The last two steps are also factorized together to emphasize that we
keep the control plane and metastore in sync.

It works by forcing a restart of the control plane if the metastore
returns an error for which we don't know if the write was a success or
not.

Closes #5008
Closes #5020
Closes #5013
fulmicoton added a commit that referenced this issue May 26, 2024
On scale up, rebalance, and get_or_open_shards, the control plane was:
- recording a shard on the metastore
- writing the shard
- record the shard on the control plane model.

Error handling was not done, so a transport failure on the metastore, or
(more likely) an error failure on init would break consistency between
the metastore and the control plane.

This PR factorizes the idea of opening a new shard for scale up,
rebalance and get_or_open_shards.

The new factorize logic goes:
- init first
- record in the metastore
- record the shard on the control plane model.

The last two steps are also factorized together to emphasize that we
keep the control plane and metastore in sync.

It works by forcing a restart of the control plane if the metastore
returns an error for which we don't know if the write was a success or
not.

Closes #5008
Closes #5020
Closes #5013
fulmicoton added a commit that referenced this issue May 26, 2024
On scale up, rebalance, and get_or_open_shards, the control plane was:
- recording a shard on the metastore
- writing the shard
- record the shard on the control plane model.

Error handling was not done, so a transport failure on the metastore, or
(more likely) an error failure on init would break consistency between
the metastore and the control plane.

This PR factorizes the idea of opening a new shard for scale up,
rebalance and get_or_open_shards.

The new factorize logic goes:
- init first
- record in the metastore
- record the shard on the control plane model.

The last two steps are also factorized together to emphasize that we
keep the control plane and metastore in sync.

It works by forcing a restart of the control plane if the metastore
returns an error for which we don't know if the write was a success or
not.

Closes #5008
Closes #5020
Closes #5013
fulmicoton added a commit that referenced this issue May 30, 2024
* Fixes control plane/metastore inconsistency due to open shard.

On scale up, rebalance, and get_or_open_shards, the control plane was:
- recording a shard on the metastore
- writing the shard
- record the shard on the control plane model.

Error handling was not done, so a transport failure on the metastore, or
(more likely) an error failure on init would break consistency between
the metastore and the control plane.

This PR factorizes the idea of opening a new shard for scale up,
rebalance and get_or_open_shards.

The new factorize logic goes:
- init first
- record in the metastore
- record the shard on the control plane model.

The last two steps are also factorized together to emphasize that we
keep the control plane and metastore in sync.

It works by forcing a restart of the control plane if the metastore
returns an error for which we don't know if the write was a success or
not.

Closes #5008
Closes #5020
Closes #5013

* Apply suggestions from code review

Co-authored-by: Adrien Guillo <adrien@quickwit.io>

* Apply suggestions from code review

Co-authored-by: Adrien Guillo <adrien@quickwit.io>

---------

Co-authored-by: Adrien Guillo <adrien@quickwit.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant