Add feature flag to disable lazy item reader (#4907)

<!-- PR description-->
AddDisableLazyItemReader disables lazy item reader, such that we fall
back to prefetch reader. This flag is currently only meant for groups
conversations backup. Although it can be utilized for other services
in future.

This flag should only be used if lazy item reader is the default choice
and we want to fallback to prefetch reader.

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [x] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* https://github.com/alcionai/corso/issues/4862

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abhishek Pandey 2023-12-22 15:59:00 -08:00 committed by GitHub
parent 127570953a
commit ddf29e98dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 0 deletions

View File

@ -75,6 +75,7 @@ func addGroupsCommands(cmd *cobra.Command) *cobra.Command {
flags.AddFetchParallelismFlag(c) flags.AddFetchParallelismFlag(c)
flags.AddDisableDeltaFlag(c) flags.AddDisableDeltaFlag(c)
flags.AddGenericBackupFlags(c) flags.AddGenericBackupFlags(c)
flags.AddDisableLazyItemReader(c)
case listCommand: case listCommand:
c, fs = utils.AddCommand(cmd, groupsListCmd(), utils.MarkPreviewCommand()) c, fs = utils.AddCommand(cmd, groupsListCmd(), utils.MarkPreviewCommand())

View File

@ -153,6 +153,7 @@ func (suite *GroupsUnitSuite) TestBackupCreateFlags() {
"--" + flags.CategoryDataFN, flagsTD.FlgInputs(flagsTD.GroupsCategoryDataInput), "--" + flags.CategoryDataFN, flagsTD.FlgInputs(flagsTD.GroupsCategoryDataInput),
"--" + flags.FetchParallelismFN, flagsTD.FetchParallelism, "--" + flags.FetchParallelismFN, flagsTD.FetchParallelism,
"--" + flags.DisableDeltaFN, "--" + flags.DisableDeltaFN,
"--" + flags.DisableLazyItemReaderFN,
}, },
flagsTD.PreparedGenericBackupFlags(), flagsTD.PreparedGenericBackupFlags(),
flagsTD.PreparedProviderFlags(), flagsTD.PreparedProviderFlags(),
@ -176,6 +177,7 @@ func (suite *GroupsUnitSuite) TestBackupCreateFlags() {
assert.True(t, co.ToggleFeatures.DisableIncrementals) assert.True(t, co.ToggleFeatures.DisableIncrementals)
assert.True(t, co.ToggleFeatures.ForceItemDataDownload) assert.True(t, co.ToggleFeatures.ForceItemDataDownload)
assert.True(t, co.ToggleFeatures.DisableDelta) assert.True(t, co.ToggleFeatures.DisableDelta)
assert.True(t, co.ToggleFeatures.DisableLazyItemReader)
assert.ElementsMatch(t, flagsTD.GroupsInput, opts.Groups) assert.ElementsMatch(t, flagsTD.GroupsInput, opts.Groups)
flagsTD.AssertGenericBackupFlags(t, cmd) flagsTD.AssertGenericBackupFlags(t, cmd)

View File

@ -10,6 +10,7 @@ const (
DeltaPageSizeFN = "delta-page-size" DeltaPageSizeFN = "delta-page-size"
DisableDeltaFN = "disable-delta" DisableDeltaFN = "disable-delta"
DisableIncrementalsFN = "disable-incrementals" DisableIncrementalsFN = "disable-incrementals"
DisableLazyItemReaderFN = "disable-lazy-item-reader"
DisableSlidingWindowLimiterFN = "disable-sliding-window-limiter" DisableSlidingWindowLimiterFN = "disable-sliding-window-limiter"
ForceItemDataDownloadFN = "force-item-data-download" ForceItemDataDownloadFN = "force-item-data-download"
EnableImmutableIDFN = "enable-immutable-id" EnableImmutableIDFN = "enable-immutable-id"
@ -29,6 +30,7 @@ var (
DeltaPageSizeFV int DeltaPageSizeFV int
DisableDeltaFV bool DisableDeltaFV bool
DisableIncrementalsFV bool DisableIncrementalsFV bool
DisableLazyItemReaderFV bool
DisableSlidingWindowLimiterFV bool DisableSlidingWindowLimiterFV bool
ForceItemDataDownloadFV bool ForceItemDataDownloadFV bool
EnableImmutableIDFV bool EnableImmutableIDFV bool
@ -178,3 +180,19 @@ func AddDisableSlidingWindowLimiterFlag(cmd *cobra.Command) {
"Disable sliding window rate limiter.") "Disable sliding window rate limiter.")
cobra.CheckErr(fs.MarkHidden(DisableSlidingWindowLimiterFN)) cobra.CheckErr(fs.MarkHidden(DisableSlidingWindowLimiterFN))
} }
// AddDisableLazyItemReader disables lazy item reader, such that we fall back to
// prefetch reader. This flag is currently only meant for groups conversations
// backup. Although it can be utilized for other services in future.
//
// This flag should only be used if lazy item reader is the default choice and
// we want to fallback to prefetch reader.
func AddDisableLazyItemReader(cmd *cobra.Command) {
fs := cmd.Flags()
fs.BoolVar(
&DisableLazyItemReaderFV,
DisableLazyItemReaderFN,
false,
"Disable lazy item reader.")
cobra.CheckErr(fs.MarkHidden(DisableLazyItemReaderFN))
}

View File

@ -26,6 +26,7 @@ func Control() control.Options {
opt.ToggleFeatures.ForceItemDataDownload = flags.ForceItemDataDownloadFV opt.ToggleFeatures.ForceItemDataDownload = flags.ForceItemDataDownloadFV
opt.ToggleFeatures.DisableDelta = flags.DisableDeltaFV opt.ToggleFeatures.DisableDelta = flags.DisableDeltaFV
opt.ToggleFeatures.DisableSlidingWindowLimiter = flags.DisableSlidingWindowLimiterFV opt.ToggleFeatures.DisableSlidingWindowLimiter = flags.DisableSlidingWindowLimiterFV
opt.ToggleFeatures.DisableLazyItemReader = flags.DisableLazyItemReaderFV
opt.ToggleFeatures.ExchangeImmutableIDs = flags.EnableImmutableIDFV opt.ToggleFeatures.ExchangeImmutableIDs = flags.EnableImmutableIDFV
opt.ToggleFeatures.UseDeltaTree = flags.UseDeltaTreeFV opt.ToggleFeatures.UseDeltaTree = flags.UseDeltaTreeFV
opt.Parallelism.ItemFetch = flags.FetchParallelismFV opt.Parallelism.ItemFetch = flags.FetchParallelismFV

View File

@ -433,6 +433,7 @@ func (suite *BackupOpUnitSuite) TestNewBackupOperation_configuredOptionsMatchInp
RunMigrations: true, RunMigrations: true,
DisableSlidingWindowLimiter: true, DisableSlidingWindowLimiter: true,
UseDeltaTree: true, UseDeltaTree: true,
DisableLazyItemReader: true,
}, },
PreviewLimits: control.PreviewItemLimits{ PreviewLimits: control.PreviewItemLimits{
MaxItems: 42, MaxItems: 42,

View File

@ -100,4 +100,13 @@ type Toggles struct {
// see: https://github.com/alcionai/corso/issues/4688 // see: https://github.com/alcionai/corso/issues/4688
UseDeltaTree bool `json:"useDeltaTree"` UseDeltaTree bool `json:"useDeltaTree"`
// AddDisableLazyItemReader disables lazy item reader, such that we fall
// back to prefetch reader. This flag is currently only meant for groups
// conversations backup. Although it can be utilized for other services
// in future.
//
// This flag should only be used if lazy item reader is the default choice
// and we want to fallback to prefetch reader.
DisableLazyItemReader bool `json:"disableLazyItemReader"`
} }