@@ -73,8 +73,6 @@ func maybeStartCompactionJob(
7373 }
7474
7575 switch {
76- case len (triggerJob .ExecutionLocality .Tiers ) != 0 :
77- return 0 , errors .New ("execution locality not supported for compaction" )
7876 case triggerJob .ScheduleID == 0 :
7977 return 0 , errors .New ("only scheduled backups can be compacted" )
8078 case len (triggerJob .SpecificTenantIds ) != 0 || triggerJob .IncludeAllSecondaryTenants :
@@ -197,13 +195,47 @@ func StartCompactionJob(
197195 scheduleID jobspb.ScheduleID ,
198196 collectionURI []string ,
199197 fullBackupPath string ,
200- encryptionOpts jobspb. BackupEncryptionOptions ,
198+ options tree. BackupOptions ,
201199 start , end hlc.Timestamp ,
202200) (jobspb.JobID , error ) {
203201 planHook , ok := planner .(sql.PlanHookState )
204202 if ! ok {
205203 return 0 , errors .New ("missing job execution context" )
206204 }
205+
206+ var executionLocality roachpb.Locality
207+ if options .ExecutionLocality != nil {
208+ if strVal , ok := options .ExecutionLocality .(* tree.StrVal ); ok {
209+ s := strVal .RawString ()
210+ if s != "" {
211+ if err := executionLocality .Set (s ); err != nil {
212+ return 0 , errors .Wrap (err , "error setting execution locality" )
213+ }
214+ }
215+ } else {
216+ return 0 , errors .Newf (
217+ "expected string value, got %+v" , options .ExecutionLocality ,
218+ )
219+ }
220+ }
221+
222+ encryption := jobspb.BackupEncryptionOptions {
223+ Mode : jobspb .EncryptionMode_None ,
224+ }
225+ if options .EncryptionPassphrase != nil {
226+ encryption .Mode = jobspb .EncryptionMode_Passphrase
227+ encryption .RawPassphrase = tree .AsStringWithFlags (
228+ options .EncryptionPassphrase ,
229+ tree .FmtBareStrings ,
230+ )
231+ }
232+ if options .EncryptionKMSURI != nil {
233+ if encryption .Mode != jobspb .EncryptionMode_None {
234+ return 0 , errors .Newf ("only one encryption mode can be specified" )
235+ }
236+ encryption .RawKmsUris = builtins .ExprSliceToStrSlice (options .EncryptionKMSURI )
237+ }
238+
207239 details := jobspb.BackupDetails {
208240 ScheduleID : scheduleID ,
209241 StartTime : start ,
@@ -213,7 +245,8 @@ func StartCompactionJob(
213245 Subdir : fullBackupPath ,
214246 Exists : true ,
215247 },
216- EncryptionOptions : & encryptionOpts ,
248+ EncryptionOptions : & encryption ,
249+ ExecutionLocality : executionLocality ,
217250 Compact : true ,
218251 }
219252 jobID := planHook .ExecCfg ().JobRegistry .MakeJobID ()
@@ -598,6 +631,7 @@ func updateCompactionBackupDetails(
598631 ResolvedCompleteDbs : lastBackup .CompleteDbs ,
599632 FullCluster : lastBackup .DescriptorCoverage == tree .AllDescriptors ,
600633 ScheduleID : initialDetails .ScheduleID ,
634+ ExecutionLocality : initialDetails .ExecutionLocality ,
601635 Compact : true ,
602636 }
603637 return compactedDetails , nil
0 commit comments