scavenger.go ×8

Frontier kind: Code frontier

unlabeled · c_ee1a7f7617c5

2 tests · 2399 LOC · 116 files · introduces 0 tests · 43 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges43 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
381 ranges2399 lines · 116 files · Browse complete extent
All tests (intent)
2 testsBrowse 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.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

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

2 files ranked by introduced lines: 43 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/worker/scanner/build_ids/scavenger.go 31 introduced LOC · 8 ranges

Open complete file

117 }
118
119 > func (a *Activities) recordHeartbeat(ctx context.Context, heartbeat heartbeatDetails) { scavenger.go
120 > activity.RecordHeartbeat(ctx, heartbeat)
121 > }
122
123 // ScavengeBuildIds scans all task queue user data entries in all namespaces and cleans up unused build ids.
262 var buildIdsToRemove []string
263 for setIdx, set := range versioningData.GetVersionSets() {
264 > // Note that setActive counts build ids that may have associated workflows, i.e. not scavenger.go
265 > // just all with STATE_ACTIVE. Also note that we always examine the default build ID
266 > // for a set last, so setActive will be 1 + the number of active non-default build ids.
267 > setActive := len(set.BuildIds)
268 > for buildIdIdx, buildId := range set.BuildIds {
269 > if buildId.State == persistencespb.STATE_DELETED {
270 setActive--
271 continue
272 }
273 > buildIdIsSetDefault := buildIdIdx == len(set.BuildIds)-1 scavenger.go
274 > setIsQueueDefault := setIdx == len(versioningData.VersionSets)-1
275 > // Don't remove if build ID is the queue default or there's another active build ID in
276 > // this set, since we might need to dispatch new tasks to this set. But if no build ids
277 > // are active for the whole set, we can remove them all.
278 > if buildIdIsSetDefault && (setIsQueueDefault || setActive > 1) {
279 > continue
280 }
281 > if hlc.Since(buildId.BecameDefaultTimestamp) < removableBuildIdDurationSinceDefault { scavenger.go
282 continue
283 }
284 > if !input.IgnoreRetentionTime && hlc.Since(buildId.StateUpdateTimestamp) < retention { scavenger.go
285 continue
286 }
287
288 > if err := rateLimiter.Wait(ctx); err != nil { scavenger.go
289 return nil, context.DeadlineExceeded
290 }
291 > exists, err := worker_versioning.WorkflowsExistForBuildId(ctx, a.visibilityManager, ns, entry.TaskQueue, buildId.Id) scavenger.go
292 > if err != nil {
293 return nil, err
294 }
295 > a.recordHeartbeat(ctx, heartbeat) scavenger.go
296 > if !exists {
297 > a.logger.Info("Found build ID to remove",
298 > tag.WorkflowNamespace(ns.Name().String()),
299 > tag.WorkflowTaskQueueName(entry.TaskQueue),
300 > tag.BuildId(buildId.Id),
301 > )
302 > buildIdsToRemove = append(buildIdsToRemove, buildId.Id)
303 > setActive--
304 > }
305 }
306 }
go.temporal.io/server/common/worker_versioning/worker_versioning.go 12 introduced LOC · 2 ranges

Open complete file

154 }
155
156 > func WorkflowsExistForBuildId(ctx context.Context, visibilityManager manager.VisibilityManager, ns *namespace.Namespace, taskQueue, buildId string) (bool, error) { worker_versioning.go
157 > escapedTaskQueue := sqlparser.String(sqlparser.NewStrVal([]byte(taskQueue)))
158 > escapedBuildId := sqlparser.String(sqlparser.NewStrVal([]byte(VersionedBuildIdSearchAttribute(buildId))))
159 > query := fmt.Sprintf("%s = %s AND %s = %s", sadefs.TaskQueue, escapedTaskQueue, sadefs.BuildIds, escapedBuildId)
160 >
161 > response, err := visibilityManager.CountWorkflowExecutions(ctx, &manager.CountWorkflowExecutionsRequest{
162 > NamespaceID: ns.ID(),
163 > Namespace: ns.Name(),
164 > Query: query,
165 > })
166 > if err != nil {
167 return false, err
168 }
169 > return response.Count > 0, nil worker_versioning.go
170 }
171