Update tabletpicker to support cell pref and tablet order options#12282
Conversation
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
If a new flag is being introduced:
If a workflow is added or modified:
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
Signed-off-by: pbibra <pbibra@slack-corp.com>
|
This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:
If no action is taken within 7 days, this PR will be closed. |
278eabd to
799c5a6
Compare
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com>
mattlord
left a comment
There was a problem hiding this comment.
Overall it looks good! Mostly minor comments/suggestions.
Beyond that, I don't see where we've added any new unit or e2e tests for this new behavior (exists tests are using the equivalent of the old behavior). We should add unit tests for this new behavior and modify the e2e tests as well, at least to use the new default preference.
I did add some new unit tests in |
Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com>
|
|
||
| - **[Major Changes](#major-changes)** | ||
| - **[Breaking Changes](#breaking-changes)** | ||
| - [Default Local Cell Preference for TabletPicker](#tablet-picker-cell-preference) |
There was a problem hiding this comment.
I don't think this needs to be in breaking changes. But I guess it doesn't hurt to increase awareness just in case we're missing some breaking case.
There was a problem hiding this comment.
I figured since we're changing default behavior it's good to advertise that? Let me know if there's another better place to do that
| _, err = tp.PickForStreaming(ctx) | ||
| require.EqualError(t, err, "context has expired") | ||
| // if local preference is selected, tp cells include's the local cell's alias | ||
| require.Greater(t, globalTPStats.noTabletFoundError.Counts()["cell_cella.ks.0.replica"], int64(0)) |
There was a problem hiding this comment.
And we assume in this case that we then use the alias?
| tp, err := NewTabletPicker(context.Background(), te.topoServ, te.cells, "cell", te.keyspace, te.shard, "replica", TabletPickerOptions{CellPreference: "OnlySpecified"}) | ||
| require.NoError(t, err) | ||
| delay := GetTabletPickerRetryDelay() | ||
| defer func() { | ||
| SetTabletPickerRetryDelay(delay) | ||
| }() | ||
| SetTabletPickerRetryDelay(11 * time.Millisecond) | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 20*time.Millisecond) | ||
| defer cancel() | ||
| // no tablets | ||
| _, err = tp.PickForStreaming(ctx) | ||
| require.EqualError(t, err, "context has expired") | ||
| // no tablets of the correct type | ||
| defer deleteTablet(t, te, addTablet(te, 200, topodatapb.TabletType_RDONLY, "cell", true, true)) | ||
| ctx, cancel = context.WithTimeout(context.Background(), 20*time.Millisecond) | ||
| defer cancel() | ||
| _, err = tp.PickForStreaming(ctx) | ||
| require.EqualError(t, err, "context has expired") |
There was a problem hiding this comment.
It's not obvious to me how we're testing OnlySpecified here? Am I missing something?
There was a problem hiding this comment.
this is showing that if the OnlySpecified option is passed into the tablet picker, but no tablet exists of that specified type, then picker cannot select a tablet
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: pbibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com>
Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com>
rohit-nayak-ps
left a comment
There was a problem hiding this comment.
Nice work! Thanks for this very useful contribution.
…tessio#12282) * update tabletpicker to support cell pref and tablet order options Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add tablet picker options in vstream flags Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add tablet picker tests Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add summary docs Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * update proto Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix vreplication test Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix doc typos, add function comments, update error handling Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix tests and comments Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * fix local cell ref Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * update proto Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add log line to debug test Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add cell to vre test def Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * define vrepl engine for controller tests Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> --------- Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: pbibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> Signed-off-by: Vilius Okockis <vilius.okockis@vinted.com>
…tessio#12282) * update tabletpicker to support cell pref and tablet order options Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add tablet picker options in vstream flags Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add tablet picker tests Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add summary docs Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * update proto Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix vreplication test Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix doc typos, add function comments, update error handling Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix tests and comments Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * fix local cell ref Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * update proto Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add log line to debug test Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add cell to vre test def Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * define vrepl engine for controller tests Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> --------- Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: pbibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> Signed-off-by: Vilius Okockis <vilius.okockis@vinted.com>
…tessio#12282) * update tabletpicker to support cell pref and tablet order options Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add tablet picker options in vstream flags Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add tablet picker tests Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add summary docs Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * update proto Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix vreplication test Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix doc typos, add function comments, update error handling Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> * fix tests and comments Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * fix local cell ref Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * update proto Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add log line to debug test Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * add cell to vre test def Signed-off-by: Priya Bibra <pbibra@slack-corp.com> * define vrepl engine for controller tests Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com> --------- Signed-off-by: Priya Bibra <pbibra@slack-corp.com> Signed-off-by: pbibra <pbibra@slack-corp.com> Signed-off-by: 'Priya Bibra' <pbibra@slack-corp.com>
Description
This PR adds options to the
TabletPickerthat allow for selecting cell preference in addition to changing default behavior to give priority to the local cell and any alias it belongs to. We are also introducing a new way to select tablet order which should eventually replace thein_order:hint currently includedtabletTypesStr.The following changes are made to the
NewTabletPickerfunction signature (i.e. theTabletPicker's instantiation):before:
after:
Where
ctx,localCell,optionare all new parameters.optionis of typeTabletPickerOptionsand includes two fields,CellPrefandTabletOrder.CellPref-> "PreferLocalWithAlias" (default) or "OnlySpecified"TabletOrder-> "Any" (default) or "InOrder"The above are defined as enum strings.
The following illustrates the behavior with different option combinations. Assume the following setup:
localCell = us-east-1aalias = region1 -> {us-east-1a, us-east-1b, us-east-1c}`cells = {us-west-1a, us-west-1b}
tablets:
When "PreferLocalWithAlias" is selected,
localCellmust be non-empty:tabletTypeStr), theTabletPickerwill first pick tablets in thelocalCelland subsequently pick tablets in any alias the local cell belongs to. Finally, it will pick tablets belonging tocellsif any additional ones are specified. The tablet type in this scenario does not matter since "Any" was selected.tabletTypeStr = REPLICA,PRIMARYtablet priority possibility:
tabletTypeStr), theTabletPickerwill first pick tablets in thelocalCellthat also respect the tablet type ordering and subsequently pick tablets in any alias the local cell belongs to with the tablet type order. Finally, it will pick tablets belonging tocellsif any additional ones are specified. The tablet type in this scenario is respected within each grouping of tablets (i.e. local cell, alias, all others)tabletTypeStr = in_order:REPLICA,PRIMARYtablet priority possibility:
When "OnlySpecified" is selected as the cell preference:
tabletTypeStr), theTabletPickerwill only pick tablets belonging to cells specified in thecellsparameter. It will ignore tablet type ordering in this case.tabletTypeStr = REPLICA,PRIMARYtablet priority possibility:
tabletTypeStr), theTabletPickerwill only pick tablets belonging to cells specified in thecellsparameter, but will respect the tablet type ordering.tabletTypeStr = in_order:REPLICA,PRIMARYtablet priority possibility:
Related Issue(s)
Checklist
docs for tabletpicker refactor website#1441