controller_impl.go ×10

Frontier kind: Code frontier

unlabeled · c_bf5cd7a60383

28 tests · 3180 LOC · 140 files · introduces 0 tests · 32 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges32 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
447 ranges3180 lines · 140 files · Browse complete extent
All tests (intent)
28 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: 32 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/shard/controller_impl.go 32 introduced LOC · 10 ranges

Open complete file

234 c.RLock()
235 if shard, ok := c.historyShards[shardID]; ok {
236 > if shard.IsValid() { controller_impl.go
237 > c.RUnlock()
238 > return shard, nil
239 > }
240 // if shard not valid then proceed to create a new one
241 }
421 }
422
423 > if readinessCtx != nil { controller_impl.go
424 > ownedShardsLock.Lock()
425 > ownedShards = append(ownedShards, shardID)
426 > ownedShardsLock.Unlock()
427 > }
428
429 > shard, err := c.GetShardByID(shardID) controller_impl.go
430 > if err != nil {
431 metrics.GetEngineForShardErrorCounter.With(c.taggedMetricsHandler).Record(1)
432 c.contextTaggedLogger.Error("Unable to create history shard context", tag.Error(err), tag.OperationFailed, tag.ShardID(shardID))
436 // Wait up to 1s for the shard to acquire the rangeid lock.
437 // After 1s we will move on but the shard will continue trying in the background.
438 > engineCtx, engineCancel := context.WithTimeout(ctx, 1*time.Second) controller_impl.go
439 > defer engineCancel()
440 > _, _ = shard.GetEngine(engineCtx)
441 }
442
470 if readinessCtx != nil {
471 if len(ownedShards) > 0 {
472 > go func() { controller_impl.go
473 > defer readinessCancel()
474 > if c.checkShardReadiness(readinessCtx, ownedShards) {
475 c.initialShardsAcquired.SetIfNotReady(struct{}{}, nil)
476 }
485 ctx context.Context,
486 shards []int32,
487 > ) bool { controller_impl.go
488 > concurrency := int64(max(c.config.AcquireShardConcurrency(), 1))
489 > sem := semaphore.NewWeighted(concurrency)
490 > var ready atomic.Int32
491 > for _, shardID := range shards {
492 > if sem.Acquire(ctx, 1) != nil {
493 return false
494 }
495 > go func() { controller_impl.go
496 > defer sem.Release(1)
497 > // Note that AssertOwnership uses a detached context for the actual persistence
498 > // op so we can't cancel it. If context is canceled, the final Acquire will
499 > // fail and we won't do anything.
500 > if shard, err := c.GetShardByID(shardID); err != nil {
501 return
502 > } else if _, err := shard.GetEngine(ctx); err != nil { controller_impl.go
503 return
504 > } else if shard.AssertOwnership(ctx) != nil { controller_impl.go
505 return
506 }
508 }()
509 }
510 > if sem.Acquire(ctx, concurrency) != nil { controller_impl.go
511 return false
512 }