temporalio / temporalio/temporal
Do not block shard ownership assertion if `acquireShards` is blocked
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.2k
- Forks
- 1.9k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 228
Description
Do not block shard ownership assertion if acquireShards is blocked
v1.17.x logic:
shard controller will start a background thread periodically asserting shard ownership
for {
select {
...
case <-acquireTicker.C:
c.acquireShards()
...
}
}
if acquireShards is blocked due to whatever reason, then no further acquireShards will be executed.
OSS team should consider the following logic
var (
ShardController struct {
...
shardAssertionInProgressMutex sync.Mutex
shardAssertionInProgress map[int32]struct{}
shardIDChan chan int32
...
}
)
func (sc *ShardController) eventLoop() {
acquireTicker := time.NewTicker(c.config.AcquireShardInterval())
defer acquireTicker.Stop()
for {
select {
case <-c.shutdownCh:
return
case <-acquireTicker.C:
for i = 0; i < totalShardIDs; i++ {
shardAssertionInProgressMutex.Lock()
_, exist = sc.shardAssertionInProgress[i]
if !exist {
sc.shardAssertionInProgress[i] = struct{}{}
}
shardAssertionInProgressMutex.Unlock()
if !exist {
sc.shardIDChan <- i
}
}
}
}
}
func (sc *ShardController) acquireShard() {
for shardID := range shardIDChan {
...
// shard ownership assertion logic here
...
shardAssertionInProgressMutex.Lock()
delete(sc.shardAssertionInProgress, shardID)
shardAssertionInProgressMutex.Unlock()
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the shard controller's eventLoop, acquireShards, and acquireShard entry points and read how the periodic ownership assertion is currently dispatched. Confirm the change keeps later shard ownership assertions running when one acquire operation blocks, while preserving shutdown behavior and preventing duplicate assertions for the same shard.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100