k-choices error handling: detect empty joins, finer fail granularity
This commit is contained in:
parent
3b6d129bfc
commit
7a87d86c32
|
@ -221,7 +221,9 @@ kChoicesNodeJoin nodeSTM bootstrapNode = do
|
||||||
-- edge case: however small the target is, at least join 1 vs
|
-- edge case: however small the target is, at least join 1 vs
|
||||||
-- kCoicesVsJoin until target is met
|
-- kCoicesVsJoin until target is met
|
||||||
joinedVss <- vsJoins vs0STM (totalCapacity ownLoadStats) (vservers node) joinLoadTarget (fromIntegral initialJoins) nodeSTM
|
joinedVss <- vsJoins vs0STM (totalCapacity ownLoadStats) (vservers node) joinLoadTarget (fromIntegral initialJoins) nodeSTM
|
||||||
liftIO . atomically . modifyTVar' nodeSTM $ \node' -> node'
|
if HMap.null joinedVss
|
||||||
|
then throwError "k-choices join unsuccessful, no vserver joined"
|
||||||
|
else liftIO . atomically . modifyTVar' nodeSTM $ \node' -> node'
|
||||||
{ vservers = HMap.union (vservers node') joinedVss }
|
{ vservers = HMap.union (vservers node') joinedVss }
|
||||||
pure ()
|
pure ()
|
||||||
|
|
||||||
|
@ -231,13 +233,14 @@ kChoicesNodeJoin nodeSTM bootstrapNode = do
|
||||||
vsJoins _ _ vsmap _ 0 _ = pure vsmap
|
vsJoins _ _ vsmap _ 0 _ = pure vsmap
|
||||||
vsJoins queryVsSTM capacity vsmap remainingTargetLoad remainingJoins nodeSTM'
|
vsJoins queryVsSTM capacity vsmap remainingTargetLoad remainingJoins nodeSTM'
|
||||||
| remainingTargetLoad <= 0 = pure vsmap
|
| remainingTargetLoad <= 0 = pure vsmap
|
||||||
| otherwise = (do
|
| otherwise = do
|
||||||
|
|
||||||
(acquiredLoad, (newNid, newVs)) <- kChoicesVsJoin queryVsSTM bootstrapNode capacity vsmap nodeSTM' remainingTargetLoad
|
(acquiredLoad, (newNid, newVs)) <- kChoicesVsJoin queryVsSTM bootstrapNode capacity vsmap nodeSTM' remainingTargetLoad
|
||||||
-- on successful vserver join add the new VS to node and recurse
|
-- on successful vserver join add the new VS to node and recurse
|
||||||
vsJoins queryVsSTM capacity (HMap.insert newNid newVs vsmap) (remainingTargetLoad - acquiredLoad) (pred remainingJoins) nodeSTM'
|
vsJoins queryVsSTM capacity (HMap.insert newNid newVs vsmap) (remainingTargetLoad - acquiredLoad) (pred remainingJoins) nodeSTM'
|
||||||
)
|
-- on error, just reduce the amount of tries and retry
|
||||||
-- TODO: decide on whether and how to catch errors
|
`catchError` (\e -> liftIO (putStrLn e) >> vsJoins queryVsSTM capacity vsmap remainingTargetLoad (pred remainingJoins) nodeSTM')
|
||||||
|
|
||||||
-- error cause 1: not a single queried node has responded -> indicates permanent failure
|
-- error cause 1: not a single queried node has responded -> indicates permanent failure
|
||||||
-- error cause 2: only a certain join failed, just ignore that join target for now, but problem: it will be the chosen
|
-- error cause 2: only a certain join failed, just ignore that join target for now, but problem: it will be the chosen
|
||||||
-- target even at the next attempt again
|
-- target even at the next attempt again
|
||||||
|
@ -284,6 +287,8 @@ kChoicesVsJoin queryVsSTM bootstrapNode capacity activeVss nodeSTM remainingTarg
|
||||||
$ segmentLoads
|
$ segmentLoads
|
||||||
-- join at min cost
|
-- join at min cost
|
||||||
joinedNode <- fediChordJoinNewVs nodeSTM vsId toJoinOn
|
joinedNode <- fediChordJoinNewVs nodeSTM vsId toJoinOn
|
||||||
|
-- idea: a single join failure shall not make the whole process fail
|
||||||
|
--`catchError`
|
||||||
pure (mincost, joinedNode)
|
pure (mincost, joinedNode)
|
||||||
|
|
||||||
-- Possible optimisation:
|
-- Possible optimisation:
|
||||||
|
|
Loading…
Reference in a new issue