diff --git a/api/schedule/v1/message.pb.go b/api/schedule/v1/message.pb.go index f6cb3f25af6..c823ac27f11 100644 --- a/api/schedule/v1/message.pb.go +++ b/api/schedule/v1/message.pb.go @@ -572,9 +572,10 @@ func (*WatchWorkflowResponse) XXX_OneofWrappers() []interface{} { } type StartWorkflowRequest struct { - Request *v14.StartWorkflowExecutionRequest `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"` - LastCompletionResult *v11.Payloads `protobuf:"bytes,4,opt,name=last_completion_result,json=lastCompletionResult,proto3" json:"last_completion_result,omitempty"` - ContinuedFailure *v12.Failure `protobuf:"bytes,5,opt,name=continued_failure,json=continuedFailure,proto3" json:"continued_failure,omitempty"` + Request *v14.StartWorkflowExecutionRequest `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"` + LastCompletionResult *v11.Payloads `protobuf:"bytes,4,opt,name=last_completion_result,json=lastCompletionResult,proto3" json:"last_completion_result,omitempty"` + ContinuedFailure *v12.Failure `protobuf:"bytes,5,opt,name=continued_failure,json=continuedFailure,proto3" json:"continued_failure,omitempty"` + CompletedRateLimitSleep bool `protobuf:"varint,6,opt,name=completed_rate_limit_sleep,json=completedRateLimitSleep,proto3" json:"completed_rate_limit_sleep,omitempty"` } func (m *StartWorkflowRequest) Reset() { *m = StartWorkflowRequest{} } @@ -630,6 +631,13 @@ func (m *StartWorkflowRequest) GetContinuedFailure() *v12.Failure { return nil } +func (m *StartWorkflowRequest) GetCompletedRateLimitSleep() bool { + if m != nil { + return m.CompletedRateLimitSleep + } + return false +} + type StartWorkflowResponse struct { RunId string `protobuf:"bytes,1,opt,name=run_id,json=runId,proto3" json:"run_id,omitempty"` RealStartTime *time.Time `protobuf:"bytes,2,opt,name=real_start_time,json=realStartTime,proto3,stdtime" json:"real_start_time,omitempty"` @@ -836,77 +844,79 @@ func init() { } var fileDescriptor_6461b6986ba20ee7 = []byte{ - // 1117 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00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, 0xf5, 0x98, 0xf1, - 0x47, 0x3d, 0xc2, 0x1e, 0x9b, 0xa8, 0x3b, 0x63, 0x51, 0x97, 0x7e, 0xe1, 0xd2, 0x3b, 0x63, 0x71, - 0x96, 0x44, 0x7d, 0x6d, 0x1c, 0xea, 0x70, 0x8e, 0xbf, 0x4c, 0xb1, 0x90, 0x01, 0xc7, 0x22, 0x61, - 0x54, 0x58, 0xdc, 0x72, 0x9f, 0xb1, 0x3e, 0xc1, 0x6d, 0x6d, 0xed, 0xa5, 0xbd, 0xb6, 0x8c, 0x07, - 0x58, 0x48, 0x34, 0x48, 0x4c, 0xc0, 0xad, 0x08, 0x27, 0x98, 0x46, 0x98, 0x86, 0x31, 0x16, 0xed, - 0x3e, 0xeb, 0x33, 0xed, 0xd7, 0x4f, 0x59, 0x48, 0xeb, 0x9b, 0x3c, 0xa8, 0xad, 0xa7, 0xbd, 0x1e, - 0xe6, 0x38, 0xda, 0x96, 0x88, 0x4b, 0x77, 0x03, 0xcc, 0x50, 0x36, 0x88, 0x29, 0x22, 0x81, 0xe2, - 0x6b, 0x38, 0x4d, 0x67, 0xa5, 0xba, 0xb6, 0xe4, 0x67, 0x87, 0xf9, 0xf6, 0x30, 0x7f, 0xc7, 0x1e, - 0xb6, 0x5e, 0x7c, 0xfa, 0xdb, 0xb2, 0x03, 0xab, 0x06, 0xa5, 0xfc, 0xee, 0x03, 0x50, 0x45, 0xa1, - 0x4c, 0x2d, 0x47, 0xfe, 0x9a, 0x1c, 0x20, 0x03, 0x69, 0x8a, 0x6d, 0x50, 0x67, 0x07, 0x98, 0x13, - 0x94, 0x04, 0x09, 0x23, 0x71, 0x78, 0xd8, 0x28, 0x34, 0x9d, 0x95, 0xfa, 0xda, 0x5b, 0xfe, 0x48, - 0x10, 0x4a, 0x09, 0xba, 0xf8, 0xfe, 0xc1, 0xaa, 0xbf, 0x6d, 0xea, 0xfb, 0x49, 0x06, 0xea, 0x6a, - 0x0c, 0xac, 0xb1, 0xb3, 0xa6, 0xbb, 0x08, 0x4a, 0x03, 0x44, 0x53, 0x44, 0x1a, 0xc5, 0xa6, 0xb3, - 0x52, 0x86, 0xc6, 0x6a, 0x7d, 0x5b, 0x04, 0xb5, 0x0e, 0x95, 0x98, 0x53, 0x44, 0xb6, 0x25, 0x92, - 0xd8, 0x7d, 0x15, 0x54, 0x28, 0x1a, 0x60, 0x91, 0xa0, 0x30, 0xab, 0x41, 0x05, 0x9e, 0x3a, 0xdc, - 0x5b, 0x60, 0x66, 0x64, 0x04, 0x71, 0xa4, 0x3f, 0xb0, 0x02, 0xab, 0x23, 0x5f, 0x27, 0x72, 0x97, - 0x41, 0xd5, 0xb6, 0x5c, 0x45, 0x94, 0x75, 0x04, 0xb0, 0xae, 0x4e, 0xe4, 0x76, 0xc1, 0x4d, 0x82, - 0x84, 0x0c, 0x12, 0xce, 0x42, 0x2c, 0x04, 0x8e, 0xb2, 0x5a, 0x15, 0xae, 0x59, 0xab, 0x39, 0x05, - 0xee, 0x5a, 0xac, 0x2e, 0xd9, 0x2e, 0xb8, 0xb1, 0x67, 0x7a, 0x19, 0x08, 0xd5, 0x4c, 0xd1, 0x28, - 0x36, 0x0b, 0x2b, 0xd5, 0x35, 0xdf, 0xbf, 0x62, 0x88, 0xfc, 0x31, 0x0d, 0xc0, 0xfa, 0xde, 0x59, - 0x53, 0xb8, 0x9f, 0x81, 0x45, 0x9d, 0x6a, 0xc8, 0x06, 0x09, 0xc1, 0x32, 0x66, 0x54, 0x69, 0x31, - 0x25, 0xb2, 0x31, 0xa5, 0xb3, 0x6d, 0x8e, 0xf7, 0x24, 0x9b, 0x41, 0x45, 0xdb, 0x45, 0x87, 0x84, - 0xa1, 0x48, 0xc0, 0x79, 0x85, 0xdf, 0x18, 0xc1, 0xa1, 0x46, 0xbb, 0x1f, 0x83, 0xb9, 0x90, 0x51, - 0x19, 0xd3, 0x14, 0x47, 0x81, 0x99, 0xc9, 0x46, 0xe9, 0x22, 0x4a, 0xf3, 0x52, 0x71, 0x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dd, 0xbf, - 0x02, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x9f, 0xa4, 0x54, 0x17, 0x0c, 0x00, 0x00, + // 1150 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0x4f, 0x6f, 0x1b, 0xc5, + 0x1b, 0xf6, 0xda, 0x8e, 0x6b, 0x8f, 0x63, 0x37, 0xd9, 0x26, 0xf9, 0x59, 0xfe, 0xc1, 0xc6, 0xb5, + 0x68, 0x09, 0x12, 0xac, 0x95, 0x54, 0xe2, 0xd0, 0xa2, 0x4a, 0x4d, 0x4a, 0x88, 0x51, 0x11, 0xd6, + 0x38, 0x10, 0xc4, 0x65, 0x35, 0xd9, 0x1d, 0x3b, 0xa3, 0xce, 0xce, 0x2c, 0x3b, 0xb3, 0x69, 0xc3, + 0x89, 0x03, 0x57, 0xa4, 0x7e, 0x07, 0x2e, 0x5c, 0x11, 0x82, 0xcf, 0xc0, 0x31, 0xc7, 0x8a, 0x0b, + 0xc4, 0xb9, 0x20, 0x71, 0xe9, 0x47, 0x40, 0x33, 0x3b, 0xeb, 0xc4, 0x4e, 0xd2, 0x04, 0x8a, 0x84, + 0xb8, 0xf9, 0x7d, 0xe7, 0x7d, 0x9e, 0x79, 0xf7, 0xfd, 0xf3, 0xec, 0x1a, 0xbc, 0x23, 0x71, 0x18, + 0xf1, 0x18, 0xd1, 0x8e, 0xc0, 0xf1, 0x3e, 0x8e, 0x3b, 0x28, 0x22, 0x1d, 0xe1, 0xef, 0xe1, 0x20, + 0xa1, 0xb8, 0xb3, 0xbf, 0xda, 0x09, 0xb1, 0x10, 0x68, 0x88, 0xdd, 0x28, 0xe6, 0x92, 0xdb, 0xcb, + 0x59, 0xb8, 0x9b, 0x86, 0xbb, 0x28, 0x22, 0x6e, 0x16, 0xee, 0xee, 0xaf, 0x36, 0xdf, 0x18, 0xf3, + 0x29, 0x22, 0x9f, 0x87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, 0x9e, 0x1f, 0x39, 0xb9, 0x17, 0x47, 0x8e, 0xf5, 0xd5, 0xc8, 0xb1, 0xbe, 0x1b, 0x39, + 0xd6, 0xcf, 0x23, 0xc7, 0x3a, 0x1c, 0x39, 0xd6, 0x6f, 0x23, 0xc7, 0xfa, 0x7d, 0xe4, 0xe4, 0x5e, + 0x8c, 0x1c, 0xeb, 0xd9, 0xb1, 0x93, 0x3b, 0x3c, 0x76, 0x72, 0xcf, 0x8f, 0x9d, 0xdc, 0xe7, 0xee, + 0x90, 0x9f, 0x64, 0x41, 0xf8, 0x05, 0xff, 0x10, 0xee, 0x65, 0xbf, 0x77, 0x4b, 0xba, 0xfb, 0x77, + 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x25, 0x91, 0x52, 0xd4, 0x54, 0x0c, 0x00, 0x00, } func (this *BufferedStart) Equal(that interface{}) bool { @@ -1236,6 +1246,9 @@ func (this *StartWorkflowRequest) Equal(that interface{}) bool { if !this.ContinuedFailure.Equal(that1.ContinuedFailure) { return false } + if this.CompletedRateLimitSleep != that1.CompletedRateLimitSleep { + return false + } return true } func (this *StartWorkflowResponse) Equal(that interface{}) bool { @@ -1469,7 +1482,7 @@ func (this *StartWorkflowRequest) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 7) + s := make([]string, 0, 8) s = append(s, "&schedule.StartWorkflowRequest{") if this.Request != nil { s = append(s, "Request: "+fmt.Sprintf("%#v", this.Request)+",\n") @@ -1480,6 +1493,7 @@ func (this *StartWorkflowRequest) GoString() string { if this.ContinuedFailure != nil { s = append(s, "ContinuedFailure: "+fmt.Sprintf("%#v", this.ContinuedFailure)+",\n") } + s = append(s, "CompletedRateLimitSleep: "+fmt.Sprintf("%#v", this.CompletedRateLimitSleep)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -2011,6 +2025,16 @@ func (m *StartWorkflowRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.CompletedRateLimitSleep { + i-- + if m.CompletedRateLimitSleep { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } if m.ContinuedFailure != nil { { size, err := m.ContinuedFailure.MarshalToSizedBuffer(dAtA[:i]) @@ -2419,6 +2443,9 @@ func (m *StartWorkflowRequest) Size() (n int) { l = m.ContinuedFailure.Size() n += 1 + l + sovMessage(uint64(l)) } + if m.CompletedRateLimitSleep { + n += 2 + } return n } @@ -2618,6 +2645,7 @@ func (this *StartWorkflowRequest) String() string { `Request:` + strings.Replace(fmt.Sprintf("%v", this.Request), "StartWorkflowExecutionRequest", "v14.StartWorkflowExecutionRequest", 1) + `,`, `LastCompletionResult:` + strings.Replace(fmt.Sprintf("%v", this.LastCompletionResult), "Payloads", "v11.Payloads", 1) + `,`, `ContinuedFailure:` + strings.Replace(fmt.Sprintf("%v", this.ContinuedFailure), "Failure", "v12.Failure", 1) + `,`, + `CompletedRateLimitSleep:` + fmt.Sprintf("%v", this.CompletedRateLimitSleep) + `,`, `}`, }, "") return s @@ -4030,6 +4058,26 @@ func (m *StartWorkflowRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CompletedRateLimitSleep", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CompletedRateLimitSleep = bool(v != 0) default: iNdEx = preIndex skippy, err := skipMessage(dAtA[iNdEx:]) diff --git a/common/dynamicconfig/constants.go b/common/dynamicconfig/constants.go index c054919a2c7..161a1aaae14 100644 --- a/common/dynamicconfig/constants.go +++ b/common/dynamicconfig/constants.go @@ -720,4 +720,6 @@ const ( // WorkerStickyCacheSize controls the sticky cache size for SDK workers on worker nodes // (shared between all workers in the process, cannot be changed after startup) WorkerStickyCacheSize = "worker.stickyCacheSize" + // SchedulerNamespaceStartWorkflowRPS is the per-namespace limit for starting workflows by schedules + SchedulerNamespaceStartWorkflowRPS = "worker.schedulerNamespaceStartWorkflowRPS" ) diff --git a/proto/internal/temporal/server/api/schedule/v1/message.proto b/proto/internal/temporal/server/api/schedule/v1/message.proto index 66e01bc375b..641ae64e5dc 100644 --- a/proto/internal/temporal/server/api/schedule/v1/message.proto +++ b/proto/internal/temporal/server/api/schedule/v1/message.proto @@ -104,6 +104,7 @@ message StartWorkflowRequest { reserved 3; temporal.api.common.v1.Payloads last_completion_result = 4; temporal.api.failure.v1.Failure continued_failure = 5; + bool completed_rate_limit_sleep = 6; } message StartWorkflowResponse { diff --git a/service/worker/batcher/fx.go b/service/worker/batcher/fx.go index 93e532abcee..d01a7da7ae3 100644 --- a/service/worker/batcher/fx.go +++ b/service/worker/batcher/fx.go @@ -94,7 +94,7 @@ func (s *workerComponent) DedicatedWorkerOptions(ns *namespace.Namespace) *worke } } -func (s *workerComponent) Register(worker sdkworker.Worker, ns *namespace.Namespace) { +func (s *workerComponent) Register(worker sdkworker.Worker, ns *namespace.Namespace, _ workercommon.RegistrationDetails) { worker.RegisterWorkflowWithOptions(BatchWorkflow, workflow.RegisterOptions{Name: BatchWFTypeName}) worker.RegisterActivity(s.activities(ns.Name(), ns.ID())) } diff --git a/service/worker/common/interface.go b/service/worker/common/interface.go index c4863afdb5d..3a5173fdb00 100644 --- a/service/worker/common/interface.go +++ b/service/worker/common/interface.go @@ -54,7 +54,7 @@ type ( PerNSWorkerComponent interface { // Register registers Workflow and Activity types provided by this worker component. // The namespace that this worker is running in is also provided. - Register(sdkworker.Worker, *namespace.Namespace) + Register(sdkworker.Worker, *namespace.Namespace, RegistrationDetails) // DedicatedWorkerOptions returns a PerNSDedicatedWorkerOptions for this worker component. DedicatedWorkerOptions(*namespace.Namespace) *PerNSDedicatedWorkerOptions } @@ -63,4 +63,14 @@ type ( // Set this to false to disable this worker for this namespace Enabled bool } + + RegistrationDetails struct { + // TotalWorkers is the number of requested per-namespace workers for this namespace. + TotalWorkers int + // Multiplicity is the number of those workers that this particular sdkworker.Worker + // represents. It may be more than one if the requested number is more than the total + // number of worker nodes or if consistent hashing decided to place more than one on + // the same node. + Multiplicity int + } ) diff --git a/service/worker/common/interface_mock.go b/service/worker/common/interface_mock.go index 13ed03f329c..f89d4367d4a 100644 --- a/service/worker/common/interface_mock.go +++ b/service/worker/common/interface_mock.go @@ -123,13 +123,13 @@ func (mr *MockPerNSWorkerComponentMockRecorder) DedicatedWorkerOptions(arg0 inte } // Register mocks base method. -func (m *MockPerNSWorkerComponent) Register(arg0 worker.Worker, arg1 *namespace.Namespace) { +func (m *MockPerNSWorkerComponent) Register(arg0 worker.Worker, arg1 *namespace.Namespace, arg2 RegistrationDetails) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Register", arg0, arg1) + m.ctrl.Call(m, "Register", arg0, arg1, arg2) } // Register indicates an expected call of Register. -func (mr *MockPerNSWorkerComponentMockRecorder) Register(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockPerNSWorkerComponentMockRecorder) Register(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Register", reflect.TypeOf((*MockPerNSWorkerComponent)(nil).Register), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Register", reflect.TypeOf((*MockPerNSWorkerComponent)(nil).Register), arg0, arg1, arg2) } diff --git a/service/worker/pernamespaceworker.go b/service/worker/pernamespaceworker.go index bc975b86ef3..ae06b7edd26 100644 --- a/service/worker/pernamespaceworker.go +++ b/service/worker/pernamespaceworker.go @@ -246,24 +246,24 @@ func (wm *perNamespaceWorkerManager) removeWorker(ns *namespace.Namespace) { delete(wm.workers, ns.ID()) } -func (wm *perNamespaceWorkerManager) getWorkerMultiplicity(ns *namespace.Namespace) (int, error) { - workerCount := wm.config.PerNamespaceWorkerCount(ns.Name().String()) - // This can result in fewer than the intended number of workers if numWorkers > 1, because +func (wm *perNamespaceWorkerManager) getWorkerMultiplicity(ns *namespace.Namespace) (int, int, error) { + totalWorkers := wm.config.PerNamespaceWorkerCount(ns.Name().String()) + // This can result in fewer than the intended number of workers if totalWorkers > 1, because // multiple lookups might land on the same node. To compensate, we increase the number of // pollers in that case, but it would be better to try to spread them across our nodes. // TODO: implement this properly using LookupN in serviceResolver multiplicity := 0 - for i := 0; i < workerCount; i++ { + for i := 0; i < totalWorkers; i++ { key := fmt.Sprintf("%s/%d", ns.ID().String(), i) target, err := wm.serviceResolver.Lookup(key) if err != nil { - return 0, err + return 0, 0, err } if target.Identity() == wm.self.Identity() { multiplicity++ } } - return multiplicity, nil + return multiplicity, totalWorkers, nil } func (wm *perNamespaceWorkerManager) getWorkerOptions(ns *namespace.Namespace) sdkWorkerOptions { @@ -379,7 +379,7 @@ func (w *perNamespaceWorker) tryRefresh(ns *namespace.Namespace) error { } // check if we are responsible for this namespace at all - multiplicity, err := w.wm.getWorkerMultiplicity(ns) + multiplicity, totalWorkers, err := w.wm.getWorkerMultiplicity(ns) if err != nil { w.logger.Error("Failed to look up hosts", tag.Error(err)) // TODO: add metric also @@ -410,7 +410,7 @@ func (w *perNamespaceWorker) tryRefresh(ns *namespace.Namespace) error { // create new one. note that even before startWorker returns, the worker may have started // and already called the fatal error handler. we need to set w.client+worker+componentSet // before releasing the lock to keep our state consistent. - client, worker, err := w.startWorker(ns, enabledComponents, multiplicity, dcOptions) + client, worker, err := w.startWorker(ns, enabledComponents, multiplicity, totalWorkers, dcOptions) if err != nil { // TODO: add metric also return err @@ -426,6 +426,7 @@ func (w *perNamespaceWorker) startWorker( ns *namespace.Namespace, components []workercommon.PerNSWorkerComponent, multiplicity int, + totalWorkers int, dcOptions sdkWorkerOptions, ) (sdkclient.Client, sdkworker.Worker, error) { nsName := ns.Name().String() @@ -456,8 +457,12 @@ func (w *perNamespaceWorker) startWorker( // this should not block because the client already has server capabilities worker := w.wm.sdkClientFactory.NewWorker(client, primitives.PerNSWorkerTaskQueue, sdkoptions) + details := workercommon.RegistrationDetails{ + TotalWorkers: totalWorkers, + Multiplicity: multiplicity, + } for _, cmp := range components { - cmp.Register(worker, ns) + cmp.Register(worker, ns, details) } // this blocks by calling DescribeNamespace a few times (with a 10s timeout) diff --git a/service/worker/pernamespaceworker_test.go b/service/worker/pernamespaceworker_test.go index 31b104fd758..61a71365e97 100644 --- a/service/worker/pernamespaceworker_test.go +++ b/service/worker/pernamespaceworker_test.go @@ -182,7 +182,7 @@ func (s *perNsWorkerManagerSuite) TestEnabled() { s.cfactory.EXPECT().NewClient(matchOptions("ns1")).Return(cli1) wkr1 := mocksdk.NewMockWorker(s.controller) s.cfactory.EXPECT().NewWorker(matchStrict{cli1}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr1) - s.cmp1.EXPECT().Register(wkr1, ns) + s.cmp1.EXPECT().Register(wkr1, ns, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) wkr1.EXPECT().Start() s.manager.namespaceCallback(ns, false) @@ -213,7 +213,7 @@ func (s *perNsWorkerManagerSuite) TestMultiplicity() { s.Equal(4, options.MaxConcurrentWorkflowTaskPollers) s.Equal(4, options.MaxConcurrentActivityTaskPollers) }).Return(wkr1) - s.cmp1.EXPECT().Register(wkr1, ns) + s.cmp1.EXPECT().Register(wkr1, ns, workercommon.RegistrationDetails{TotalWorkers: 3, Multiplicity: 2}) wkr1.EXPECT().Start() s.manager.namespaceCallback(ns, false) @@ -258,7 +258,7 @@ func (s *perNsWorkerManagerSuite) TestOptions() { s.Equal(0.0, options.WorkerLocalActivitiesPerSecond) s.Equal(0*time.Millisecond, options.StickyScheduleToStartTimeout) }).Return(wkr) - s.cmp1.EXPECT().Register(wkr, gomock.Any()).AnyTimes() + s.cmp1.EXPECT().Register(wkr, gomock.Any(), gomock.Any()).AnyTimes() wkr.EXPECT().Start().AnyTimes() s.manager.namespaceCallback(ns1, false) @@ -302,9 +302,9 @@ func (s *perNsWorkerManagerSuite) TestTwoNamespacesTwoComponents() { s.cfactory.EXPECT().NewWorker(matchStrict{cli1}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr1) s.cfactory.EXPECT().NewWorker(matchStrict{cli2}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr2) - s.cmp1.EXPECT().Register(wkr1, ns1) - s.cmp1.EXPECT().Register(wkr2, ns2) - s.cmp2.EXPECT().Register(wkr1, ns1) + s.cmp1.EXPECT().Register(wkr1, ns1, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) + s.cmp1.EXPECT().Register(wkr2, ns2, workercommon.RegistrationDetails{TotalWorkers: 2, Multiplicity: 2}) + s.cmp2.EXPECT().Register(wkr1, ns1, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) wkr1.EXPECT().Start() wkr2.EXPECT().Start() @@ -334,7 +334,7 @@ func (s *perNsWorkerManagerSuite) TestDeleteNs() { s.cfactory.EXPECT().NewClient(matchOptions("ns1")).Return(cli1) wkr1 := mocksdk.NewMockWorker(s.controller) s.cfactory.EXPECT().NewWorker(matchStrict{cli1}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr1) - s.cmp1.EXPECT().Register(wkr1, ns) + s.cmp1.EXPECT().Register(wkr1, ns, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) wkr1.EXPECT().Start() s.manager.namespaceCallback(ns, false) @@ -354,7 +354,7 @@ func (s *perNsWorkerManagerSuite) TestDeleteNs() { s.cfactory.EXPECT().NewClient(matchOptions("ns1")).Return(cli2) wkr2 := mocksdk.NewMockWorker(s.controller) s.cfactory.EXPECT().NewWorker(matchStrict{cli2}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr2) - s.cmp1.EXPECT().Register(wkr2, ns) + s.cmp1.EXPECT().Register(wkr2, ns, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) wkr2.EXPECT().Start() s.manager.namespaceCallback(nsRestored, false) @@ -389,7 +389,7 @@ func (s *perNsWorkerManagerSuite) TestMembershipChanged() { s.cfactory.EXPECT().NewClient(matchOptions("ns1")).Return(cli1) wkr1 := mocksdk.NewMockWorker(s.controller) s.cfactory.EXPECT().NewWorker(matchStrict{cli1}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr1) - s.cmp1.EXPECT().Register(wkr1, ns) + s.cmp1.EXPECT().Register(wkr1, ns, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) wkr1.EXPECT().Start() s.manager.membershipChangedCh <- nil @@ -422,7 +422,7 @@ func (s *perNsWorkerManagerSuite) TestServiceResolverError() { s.cfactory.EXPECT().NewClient(matchOptions("ns1")).Return(cli1) wkr1 := mocksdk.NewMockWorker(s.controller) s.cfactory.EXPECT().NewWorker(matchStrict{cli1}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr1) - s.cmp1.EXPECT().Register(wkr1, ns) + s.cmp1.EXPECT().Register(wkr1, ns, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) wkr1.EXPECT().Start() s.manager.namespaceCallback(ns, false) @@ -449,7 +449,7 @@ func (s *perNsWorkerManagerSuite) TestStartWorkerError() { s.cfactory.EXPECT().NewClient(matchOptions("ns1")).Return(cli1) wkr1 := mocksdk.NewMockWorker(s.controller) s.cfactory.EXPECT().NewWorker(matchStrict{cli1}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr1) - s.cmp1.EXPECT().Register(wkr1, ns) + s.cmp1.EXPECT().Register(wkr1, ns, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) // first try fails to start wkr1.EXPECT().Start().Return(errors.New("start worker error")) @@ -460,7 +460,7 @@ func (s *perNsWorkerManagerSuite) TestStartWorkerError() { s.cfactory.EXPECT().NewClient(matchOptions("ns1")).Return(cli2) wkr2 := mocksdk.NewMockWorker(s.controller) s.cfactory.EXPECT().NewWorker(matchStrict{cli2}, primitives.PerNSWorkerTaskQueue, gomock.Any()).Return(wkr2) - s.cmp1.EXPECT().Register(wkr2, ns) + s.cmp1.EXPECT().Register(wkr2, ns, workercommon.RegistrationDetails{TotalWorkers: 1, Multiplicity: 1}) wkr2.EXPECT().Start() s.manager.namespaceCallback(ns, false) diff --git a/service/worker/scheduler/activities.go b/service/worker/scheduler/activities.go index ba608defa78..58530fad678 100644 --- a/service/worker/scheduler/activities.go +++ b/service/worker/scheduler/activities.go @@ -44,6 +44,7 @@ import ( "go.temporal.io/server/common" "go.temporal.io/server/common/namespace" "go.temporal.io/server/common/primitives/timestamp" + "go.temporal.io/server/common/quotas" ) type ( @@ -51,9 +52,16 @@ type ( activityDeps namespace namespace.Name namespaceID namespace.ID + // Rate limiter for start workflow requests. Note that the scope is all schedules in + // this namespace on this worker. + startWorkflowRateLimiter quotas.RateLimiter } errFollow string + + rateLimitedDetails struct { + Delay time.Duration + } ) var ( @@ -61,11 +69,27 @@ var ( errWrongChain = errors.New("found running workflow with wrong FirstExecutionRunId") errNoEvents = errors.New("GetEvents didn't return any events") errNoAttrs = errors.New("last event did not have correct attrs") + errBlocked = errors.New("rate limiter doesn't allow any progress") ) func (e errFollow) Error() string { return string(e) } func (a *activities) StartWorkflow(ctx context.Context, req *schedspb.StartWorkflowRequest) (*schedspb.StartWorkflowResponse, error) { + if !req.CompletedRateLimitSleep { + reservation := a.startWorkflowRateLimiter.Reserve() + if !reservation.OK() { + return nil, translateError(errBlocked, "StartWorkflowExecution") + } + delay := reservation.Delay() + if delay > 1*time.Second { + // for a long sleep, ask the workflow to do it in workflow logic + return nil, temporal.NewNonRetryableApplicationError( + rateLimitedErrorType, rateLimitedErrorType, nil, rateLimitedDetails{Delay: delay}) + } + // short sleep can be done in-line + time.Sleep(delay) + } + req.Request.Namespace = a.namespace.String() request := common.CreateHistoryStartWorkflowRequest( diff --git a/service/worker/scheduler/fx.go b/service/worker/scheduler/fx.go index 70deda320e5..3b7414f7c06 100644 --- a/service/worker/scheduler/fx.go +++ b/service/worker/scheduler/fx.go @@ -36,6 +36,7 @@ import ( "go.temporal.io/server/common/log" "go.temporal.io/server/common/metrics" "go.temporal.io/server/common/namespace" + "go.temporal.io/server/common/quotas" workercommon "go.temporal.io/server/service/worker/common" ) @@ -46,8 +47,9 @@ const ( type ( workerComponent struct { - activityDeps activityDeps - enabledForNs dynamicconfig.BoolPropertyFnWithNamespaceFilter + activityDeps activityDeps + enabledForNs dynamicconfig.BoolPropertyFnWithNamespaceFilter + globalNSStartWorkflowRPS dynamicconfig.FloatPropertyFnWithNamespaceFilter } activityDeps struct { @@ -77,6 +79,8 @@ func NewResult( activityDeps: params, enabledForNs: dcCollection.GetBoolPropertyFnWithNamespaceFilter( dynamicconfig.WorkerEnableScheduler, true), + globalNSStartWorkflowRPS: dcCollection.GetFloatPropertyFilteredByNamespace( + dynamicconfig.SchedulerNamespaceStartWorkflowRPS, 30.0), }, } } @@ -87,15 +91,19 @@ func (s *workerComponent) DedicatedWorkerOptions(ns *namespace.Namespace) *worke } } -func (s *workerComponent) Register(worker sdkworker.Worker, ns *namespace.Namespace) { +func (s *workerComponent) Register(worker sdkworker.Worker, ns *namespace.Namespace, details workercommon.RegistrationDetails) { worker.RegisterWorkflowWithOptions(SchedulerWorkflow, workflow.RegisterOptions{Name: WorkflowType}) - worker.RegisterActivity(s.activities(ns.Name(), ns.ID())) + worker.RegisterActivity(s.activities(ns.Name(), ns.ID(), details)) } -func (s *workerComponent) activities(name namespace.Name, id namespace.ID) *activities { +func (s *workerComponent) activities(name namespace.Name, id namespace.ID, details workercommon.RegistrationDetails) *activities { + localRPS := func() float64 { + return float64(details.Multiplicity) * s.globalNSStartWorkflowRPS(name.String()) / float64(details.TotalWorkers) + } return &activities{ - activityDeps: s.activityDeps, - namespace: name, - namespaceID: id, + activityDeps: s.activityDeps, + namespace: name, + namespaceID: id, + startWorkflowRateLimiter: quotas.NewDefaultOutgoingRateLimiter(localRPS), } } diff --git a/service/worker/scheduler/workflow.go b/service/worker/scheduler/workflow.go index d1d46ee9464..0d2c05bc76b 100644 --- a/service/worker/scheduler/workflow.go +++ b/service/worker/scheduler/workflow.go @@ -73,6 +73,8 @@ const ( maxListMatchingTimesCount = 1000 invalidDuration time.Duration = -1 + + rateLimitedErrorType = "RateLimited" ) type ( @@ -676,6 +678,7 @@ func (s *scheduler) addStart(nominalTime, actualTime time.Time, overlapPolicy en } // processBuffer should return true if there might be more work to do right now. +// //nolint:revive func (s *scheduler) processBuffer() bool { s.logger.Debug("processBuffer", "buffer", len(s.State.BufferedStarts), "running", len(s.Info.RunningWorkflows), "needRefresh", s.State.NeedRefresh) @@ -810,20 +813,32 @@ func (s *scheduler) startWorkflow( LastCompletionResult: s.State.LastCompletionResult, ContinuedFailure: s.State.ContinuedFailure, } - var res schedspb.StartWorkflowResponse - err := workflow.ExecuteLocalActivity(ctx, s.a.StartWorkflow, req).Get(s.ctx, &res) - if err != nil { - return nil, err - } + for { + var res schedspb.StartWorkflowResponse + err := workflow.ExecuteLocalActivity(ctx, s.a.StartWorkflow, req).Get(s.ctx, &res) + + var appErr *temporal.ApplicationError + var details rateLimitedDetails + if errors.As(err, &appErr) && + appErr.Type() == rateLimitedErrorType && + appErr.Details(&details) == nil { + workflow.Sleep(s.ctx, details.Delay) + req.CompletedRateLimitSleep = true // only use rate limiter once + continue + } + if err != nil { + return nil, err + } - return &schedpb.ScheduleActionResult{ - ScheduleTime: start.ActualTime, - ActualTime: res.RealStartTime, - StartWorkflowResult: &commonpb.WorkflowExecution{ - WorkflowId: workflowID, - RunId: res.RunId, - }, - }, nil + return &schedpb.ScheduleActionResult{ + ScheduleTime: start.ActualTime, + ActualTime: res.RealStartTime, + StartWorkflowResult: &commonpb.WorkflowExecution{ + WorkflowId: workflowID, + RunId: res.RunId, + }, + }, nil + } } func (s *scheduler) identity() string { diff --git a/tests/schedule_test.go b/tests/schedule_test.go index 5eed6467935..17013f4f891 100644 --- a/tests/schedule_test.go +++ b/tests/schedule_test.go @@ -46,6 +46,7 @@ import ( "go.temporal.io/sdk/worker" "go.temporal.io/sdk/workflow" + "go.temporal.io/server/common/dynamicconfig" "go.temporal.io/server/common/log/tag" "go.temporal.io/server/common/payload" "go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite" @@ -547,3 +548,82 @@ func (s *scheduleIntegrationSuite) TestRefresh() { events3 := s.getHistory(s.namespace, &commonpb.WorkflowExecution{WorkflowId: scheduler.WorkflowIDPrefix + sid}) s.Greater(len(events3), len(events2)) } + +func (s *scheduleIntegrationSuite) TestRateLimit() { + sid := "sched-test-rate-limit-%d" + wid := "sched-test-rate-limit-wf-%d" + wt := "sched-test-rate-limit-wt" + + // Set 1/sec rate limit per namespace. To force this to take effect immediately (instead of + // waiting one minute) we have to cause the whole worker to be stopped and started. The + // sleeps are needed because the refresh is asynchronous, and there's no way to get access + // to the actual rate limiter object to refresh it directly. + s.testCluster.host.dcClient.OverrideValue(dynamicconfig.SchedulerNamespaceStartWorkflowRPS, 1.0) + s.testCluster.host.dcClient.OverrideValue(dynamicconfig.WorkerPerNamespaceWorkerCount, 0) + s.testCluster.host.workerService.RefreshPerNSWorkerManager() + time.Sleep(2 * time.Second) + s.testCluster.host.dcClient.RemoveOverride(dynamicconfig.WorkerPerNamespaceWorkerCount) + s.testCluster.host.workerService.RefreshPerNSWorkerManager() + time.Sleep(2 * time.Second) + + var runs int32 + workflowFn := func(ctx workflow.Context) error { + workflow.SideEffect(ctx, func(ctx workflow.Context) any { + atomic.AddInt32(&runs, 1) + return 0 + }) + return nil + } + s.worker.RegisterWorkflowWithOptions(workflowFn, workflow.RegisterOptions{Name: wt}) + + // create 10 copies of the schedule + for i := 0; i < 10; i++ { + schedule := &schedulepb.Schedule{ + Spec: &schedulepb.ScheduleSpec{ + Interval: []*schedulepb.IntervalSpec{ + {Interval: timestamp.DurationPtr(1 * time.Second)}, + }, + }, + Action: &schedulepb.ScheduleAction{ + Action: &schedulepb.ScheduleAction_StartWorkflow{ + StartWorkflow: &workflowpb.NewWorkflowExecutionInfo{ + WorkflowId: fmt.Sprintf(wid, i), + WorkflowType: &commonpb.WorkflowType{Name: wt}, + TaskQueue: &taskqueuepb.TaskQueue{Name: s.taskQueue}, + }, + }, + }, + } + _, err := s.engine.CreateSchedule(NewContext(), &workflowservice.CreateScheduleRequest{ + Namespace: s.namespace, + ScheduleId: fmt.Sprintf(sid, i), + Schedule: schedule, + Identity: "test", + RequestId: uuid.New(), + }) + s.NoError(err) + } + + time.Sleep(5 * time.Second) + + // With no rate limit, we'd see 10/second == 50 workflows run. With a limit of 1/sec, we + // expect to see around 5. + s.Less(atomic.LoadInt32(&runs), int32(10)) + + // clean up + for i := 0; i < 10; i++ { + _, err := s.engine.DeleteSchedule(NewContext(), &workflowservice.DeleteScheduleRequest{ + Namespace: s.namespace, + ScheduleId: fmt.Sprintf(sid, i), + Identity: "test", + }) + s.NoError(err) + } + + s.testCluster.host.dcClient.RemoveOverride(dynamicconfig.SchedulerNamespaceStartWorkflowRPS) + s.testCluster.host.dcClient.OverrideValue(dynamicconfig.WorkerPerNamespaceWorkerCount, 0) + s.testCluster.host.workerService.RefreshPerNSWorkerManager() + time.Sleep(2 * time.Second) + s.testCluster.host.dcClient.RemoveOverride(dynamicconfig.WorkerPerNamespaceWorkerCount) + s.testCluster.host.workerService.RefreshPerNSWorkerManager() +}