From 302be45a9abe0911e57d1acf55ed165e4f757fd7 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey Date: Fri, 18 Aug 2023 20:18:17 +0530 Subject: [PATCH] Reduce select query for url cache delta query --- .../m365/collection/drive/collections.go | 2 +- src/internal/operations/backup.go | 62 +++++++++---------- src/pkg/services/m365/api/config.go | 6 ++ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/internal/m365/collection/drive/collections.go b/src/internal/m365/collection/drive/collections.go index 9df725442..410bd752d 100644 --- a/src/internal/m365/collection/drive/collections.go +++ b/src/internal/m365/collection/drive/collections.go @@ -473,7 +473,7 @@ func (c *Collections) addURLCacheToDriveCollections( driveID, prevDelta, urlCacheRefreshInterval, - c.handler.NewItemPager(driveID, "", api.DriveItemSelectDefault()), + c.handler.NewItemPager(driveID, "", api.DriveItemSelectURLCache()), errs) if err != nil { return err diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index a06d09080..ef924ff47 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -369,41 +369,41 @@ func (op *BackupOperation) do( lastBackupVersion = mans.MinBackupVersion() } - // Run 3 times and exit - cs := []data.BackupCollection{} - canUsePreviousBackup := false + // // Run 3 times and exit + // cs := []data.BackupCollection{} + // canUsePreviousBackup := false - var maxCount int = 2 + // var maxCount int = 2 - for i := 0; i < maxCount; i++ { - logger.Ctx(ctx).Info("delta query iteration") + // for i := 0; i < maxCount; i++ { + logger.Ctx(ctx).Info("delta query iteration") - cs, _, canUsePreviousBackup, err := produceBackupDataCollections( - ctx, - op.bp, - op.ResourceOwner, - op.Selectors, - mdColls, - lastBackupVersion, - op.Options, - op.Errors) - if err != nil { - return nil, clues.Wrap(err, "producing backup data collections") - } - - ctx = clues.Add( - ctx, - "can_use_previous_backup", canUsePreviousBackup, - "collection_count", len(cs)) - - // sleep for 5 mins - //time.Sleep(5 * time.Minute) - - if i == maxCount-1 { - return nil, clues.New("unable to produce backup collections").WithClues(ctx) - } + cs, ssmb, canUsePreviousBackup, err := produceBackupDataCollections( + ctx, + op.bp, + op.ResourceOwner, + op.Selectors, + mdColls, + lastBackupVersion, + op.Options, + op.Errors) + if err != nil { + return nil, clues.Wrap(err, "producing backup data collections") } + ctx = clues.Add( + ctx, + "can_use_previous_backup", canUsePreviousBackup, + "collection_count", len(cs)) + + // sleep for 5 mins + //time.Sleep(5 * time.Minute) + + // if i == maxCount-1 { + // return nil, clues.New("unable to produce backup collections").WithClues(ctx) + // } + // } + writeStats, deets, toMerge, err := consumeBackupCollections( ctx, op.kopia, @@ -411,7 +411,7 @@ func (op *BackupOperation) do( reasons, mans, cs, - nil, + ssmb, backupID, op.incremental && canUseMetadata && canUsePreviousBackup, op.Errors) diff --git a/src/pkg/services/m365/api/config.go b/src/pkg/services/m365/api/config.go index 9e2247279..0c3b799a3 100644 --- a/src/pkg/services/m365/api/config.go +++ b/src/pkg/services/m365/api/config.go @@ -94,6 +94,12 @@ func idAnd(ss ...string) []string { // exported // --------------------------------------------------------------------------- +func DriveItemSelectURLCache() []string { + return idAnd( + "deleted", + ) +} + func DriveItemSelectDefault() []string { return idAnd( "content.downloadUrl",