pri_task_reader.go ×13

Frontier kind: Code frontier

unlabeled · c_5261d1b75df2

45 tests · 3608 LOC · 152 files · introduces 0 tests · 38 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges38 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
614 ranges3608 lines · 152 files · Browse complete extent
All tests (intent)
45 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.

1 file ranked by introduced lines: 38 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/matching/pri_task_reader.go 38 introduced LOC · 13 ranges

Open complete file

131
132 // On other errors: ask backlog manager to re-spool to persistence
133 > if err != nil { pri_task_reader.go
134 if tr.backlogMgr.respoolTaskAfterError(task.event.Data) != nil {
135 return // task queue will unload now
137 }
138
139 > tr.lock.Lock() pri_task_reader.go
140 > defer tr.lock.Unlock()
141 >
142 > tr.backlogAge.record(task.event.Data.CreateTime, -1)
143 >
144 > numAcked := tr.ackTaskLocked(task.event.TaskId)
145 >
146 > tr.maybeGCLocked()
147 >
148 > // use == so we just signal once when we cross this threshold
149 > // TODO(pri): is this safe? maybe we need to improve this
150 > if tr.loadedTasks == tr.backlogMgr.config.GetTasksReloadAt() {
151 tr.SignalTaskLoading()
152 }
153
154 > tr.backlogMgr.db.updateAckLevelAndBacklogStats(tr.subqueue, tr.ackLevel, -numAcked, tr.backlogAge.oldestTime()) pri_task_reader.go
155 }
156
437 }
438
439 > func (tr *priTaskReader) ackTaskLocked(taskId int64) int64 { pri_task_reader.go
440 > wasAlreadyAcked, found := tr.outstandingTasks.Get(taskId)
441 > if !softassert.That(tr.logger, found, "completed task not found in oustandingTasks") {
442 return 0
443 }
444 > if !softassert.That(tr.logger, !wasAlreadyAcked.(bool), "completed task was already acked") { pri_task_reader.go
445 return 0
446 }
447
448 > tr.outstandingTasks.Put(taskId, true) pri_task_reader.go
449 > tr.loadedTasks--
450 >
451 > // Adjust the ack level as far as we can
452 > var numAcked int64
453 > for {
454 > minId, acked := tr.outstandingTasks.Min()
455 > if minId == nil || !acked.(bool) {
456 > break
457 }
458 > tr.ackLevel = minId.(int64) // nolint:revive pri_task_reader.go
459 > tr.outstandingTasks.Remove(minId)
460 > numAcked += 1
461 }
462
463 // Also if we're completely drained, we can move the ack level up to the read level.
464 > if tr.isDrainedLocked() { pri_task_reader.go
465 tr.ackLevel = tr.readLevel
466 }
467
468 > return numAcked pri_task_reader.go
469 }
470
496 // gc
497
498 > func (tr *priTaskReader) maybeGCLocked() { pri_task_reader.go
499 > if !tr.shouldGCLocked() {
500 return
501 }
506 }
507
508 > func (tr *priTaskReader) shouldGCLocked() bool { pri_task_reader.go
509 > if tr.inGC {
510 return false
511 > } else if gcGap := int(tr.ackLevel - tr.gcAckLevel); gcGap == 0 { pri_task_reader.go
512 return false
513 > } else if gcGap >= tr.backlogMgr.config.MaxTaskDeleteBatchSize() { pri_task_reader.go
514 return true
515 }