scavenger.go ×16

Frontier kind: Joint frontier

unlabeled · c_66f79f997660

1 test · 2694 LOC · 124 files · introduces 1 test · 84 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
19 ranges84 lines · 3 files
Tests
1 test

Contains — complete concept membership

All code (extent)
460 ranges2694 lines · 124 files · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 84 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/worker/scanner/build_ids/scavenger.go 72 introduced LOC · 16 ranges

Open complete file

108 }
109
110 > func (a *Activities) setDefaults(input *BuildIdScavangerInput) { scavenger.go
111 > if input.NamespaceListPageSize == 0 {
112 > input.NamespaceListPageSize = 100
113 > }
114 > if input.TaskQueueListPageSize == 0 {
115 > input.TaskQueueListPageSize = 100
116 > }
117 }
118
122
123 // ScavengeBuildIds scans all task queue user data entries in all namespaces and cleans up unused build ids.
124 > func (a *Activities) ScavengeBuildIds(ctx context.Context, input BuildIdScavangerInput) error { scavenger.go
125 > a.setDefaults(&input)
126 >
127 > var heartbeat heartbeatDetails
128 > if activity.HasHeartbeatDetails(ctx) {
129 > if err := activity.GetHeartbeatDetails(ctx, &heartbeat); err != nil {
130 return temporal.NewNonRetryableApplicationError("failed to load previous heartbeat details", "TypeError", err)
131 }
132 }
133 > rateLimiter := quotas.NewDefaultOutgoingRateLimiter(quotas.RateFn(a.buildIdScavengerVisibilityRPS)) scavenger.go
134 > for {
135 > nsResponse, err := a.metadataManager.ListNamespaces(ctx, &persistence.ListNamespacesRequest{
136 > PageSize: input.NamespaceListPageSize,
137 > NextPageToken: heartbeat.NamespaceNextPageToken,
138 > IncludeDeleted: false, // Don't care about deleted namespaces.
139 > })
140 > if err != nil {
141 return err
142 }
143 > for heartbeat.NamespaceIdx < len(nsResponse.Namespaces) { scavenger.go
144 > nsId := nsResponse.Namespaces[heartbeat.NamespaceIdx].Namespace.Info.Id
145 > if err := a.processNamespaceEntry(ctx, rateLimiter, input, &heartbeat, nsId); err != nil {
146 return err
147 }
148 > heartbeat.NamespaceIdx++ scavenger.go
149 > a.recordHeartbeat(ctx, heartbeat)
150 }
151 > heartbeat.NamespaceIdx = 0 scavenger.go
152 > heartbeat.NamespaceNextPageToken = nsResponse.NextPageToken
153 > if len(heartbeat.NamespaceNextPageToken) == 0 {
154 > break
155 }
156 > a.recordHeartbeat(ctx, heartbeat) scavenger.go
157 }
158 > return nil scavenger.go
159 }
160
165 heartbeat *heartbeatDetails,
166 nsId string,
167 > ) error { scavenger.go
168 > ns, err := a.namespaceRegistry.GetNamespaceByID(namespace.ID(nsId))
169 > if err != nil {
170 return err
171 }
172 // Only the active cluster for this namespace should perform the cleanup.
173 //nolint:forbidigo // scavenger scans entire namespace, not per workflow.
174 > if !ns.ActiveInCluster(a.currentClusterName) { scavenger.go
175 > return nil
176 > }
177 > for {
178 > tqResponse, err := a.taskManager.ListTaskQueueUserDataEntries(ctx, &persistence.ListTaskQueueUserDataEntriesRequest{
179 > NamespaceID: nsId,
180 > PageSize: input.TaskQueueListPageSize,
181 > NextPageToken: heartbeat.TaskQueueNextPageToken,
182 > })
183 > if err != nil {
184 return err
185 }
186 > for heartbeat.TaskQueueIdx < len(tqResponse.Entries) { scavenger.go
187 > entry := tqResponse.Entries[heartbeat.TaskQueueIdx]
188 > if err := a.processUserDataEntry(ctx, rateLimiter, input, *heartbeat, ns, entry); err != nil {
189 if common.IsContextDeadlineExceededErr(err) {
190 // This is either a real DeadlineExceeded from the context, or the rate limiter
201 tag.Error(err))
202 }
203 > heartbeat.TaskQueueIdx++ scavenger.go
204 > a.recordHeartbeat(ctx, *heartbeat)
205 }
206 > heartbeat.TaskQueueIdx = 0 scavenger.go
207 > heartbeat.TaskQueueNextPageToken = tqResponse.NextPageToken
208 > if len(heartbeat.TaskQueueNextPageToken) == 0 {
209 > break
210 }
211 a.recordHeartbeat(ctx, *heartbeat)
212 }
213 > return nil scavenger.go
214 }
215
221 ns *namespace.Namespace,
222 entry *persistence.TaskQueueUserDataEntry,
223 > ) error { scavenger.go
224 > buildIdsToRemove, err := a.findBuildIdsToRemove(ctx, rateLimiter, input, heartbeat, ns, entry)
225 > if err != nil {
226 return err
227 }
228 > if len(buildIdsToRemove) == 0 { scavenger.go
229 > return nil
230 > }
231 > _, err = a.matchingClient.UpdateWorkerBuildIdCompatibility(ctx, &matchingservice.UpdateWorkerBuildIdCompatibilityRequest{
232 > NamespaceId: ns.ID().String(),
233 > TaskQueue: entry.TaskQueue,
234 > Operation: &matchingservice.UpdateWorkerBuildIdCompatibilityRequest_RemoveBuildIds_{
235 > RemoveBuildIds: &matchingservice.UpdateWorkerBuildIdCompatibilityRequest_RemoveBuildIds{
236 > KnownUserDataVersion: entry.UserData.Version,
237 > BuildIds: buildIdsToRemove,
238 > },
239 > },
240 > })
241 > return err
242 }
243
go.temporal.io/server/api/matchingservicemock/v1/service_grpc.pb.mock.go 8 introduced LOC · 2 ranges

Open complete file

844
845 // UpdateWorkerBuildIdCompatibility mocks base method.
846 > func (m *MockMatchingServiceClient) UpdateWorkerBuildIdCompatibility(ctx context.Context, in *matchingservice.UpdateWorkerBuildIdCompatibilityRequest, opts ...grpc.CallOption) (*matchingservice.UpdateWorkerBuildIdCompatibilityResponse, error) { service_grpc.pb.mock.go
847 > m.ctrl.T.Helper()
848 > varargs := []any{ctx, in}
849 > for _, a := range opts {
850 varargs = append(varargs, a)
851 }
852 > ret := m.ctrl.Call(m, "UpdateWorkerBuildIdCompatibility", varargs...) service_grpc.pb.mock.go
853 > ret0, _ := ret[0].(*matchingservice.UpdateWorkerBuildIdCompatibilityResponse)
854 > ret1, _ := ret[1].(error)
855 > return ret0, ret1
856 }
857
go.temporal.io/server/api/matchingservice/v1/request_response.pb.go 4 introduced LOC · 1 range

Open complete file

6003 }
6004
6005 > func (x *UpdateWorkerBuildIdCompatibilityRequest_RemoveBuildIds) GetBuildIds() []string { request_response.pb.go
6006 > if x != nil {
6007 > return x.BuildIds
6008 > }
6009 return nil
6010 }