You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Say that some replica group G3, when transitioning to C, needs shard S1 from G1, and shard S2 from G2. We really want G3 > to immediately start serving a shard once it has received the necessary state, even if it is still waiting for some other shards. > For example, if G1 is down, G3 should still start serving requests for S2 once it receives the appropriate data from G2,
despite the transition to C not yet having completed.
In your code, the reonfiguration code is an "atomic" operation. you should get all fetched shard data, and then write into raft and apply. And then it can serve for client.
Personally, it cannot do the above situation.
By the way, thanks for your sharing code which helped me a lot.
func (kv*ShardKV) getReconfigureEntry(nextConfig shardmaster.Config) (Op, bool) {
entry:=Op{}
entry.Command="reconfigure"entry.Config=nextConfigfori:=0; i<shardmaster.NShards; i++ {
entry.Data[i] =make(map[string]string)
}
entry.Ack=make(map[int64]int64)
ok:=truevarackMu sync.Mutexvarwg sync.WaitGrouptransferShards:=kv.getShardsToTransfer(nextConfig)
forgid, shardIds:=rangetransferShards {
wg.Add(1)
gofunc(gidint, argsTransferShardArgs, replyTransferShardReply) {
deferwg.Done()
ifkv.sendTransferShard(gid, &args, &reply) {
ackMu.Lock()
// copy only shards requested from that replica group to reconfigure argsfor_, shardId:=rangeargs.ShardIds {
shardData:=reply.Data[shardId]
fork, v:=rangeshardData {
entry.Data[shardId][k] =v
}
}
// merge ack map from that replica group to reconfigure argsforclientId:=rangereply.Ack {
if_, ok:=entry.Ack[clientId]; !ok||entry.Ack[clientId] <reply.Ack[clientId] {
entry.Ack[clientId] =reply.Ack[clientId]
}
}
ackMu.Unlock()
} else {
ok=false
}
}(gid, TransferShardArgs{Num: nextConfig.Num, ShardIds: shardIds}, TransferShardReply{})
}
wg.Wait()
returnentry, ok
}
The text was updated successfully, but these errors were encountered:
Challenge 2 descirbe a situation
In your code, the reonfiguration code is an "atomic" operation. you should get all fetched shard data, and then write into raft and apply. And then it can serve for client.
Personally, it cannot do the above situation.
By the way, thanks for your sharing code which helped me a lot.
The text was updated successfully, but these errors were encountered: