forked from informatikr/hedis
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One pool per node test #24
Draft
shashitnak
wants to merge
23
commits into
juspay:cluster
Choose a base branch
from
shashitnak:one-pool-per-node-test
base: cluster
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
10e07f3
Merge pull request #4 from juspay/cluster
aravindgopall 910977c
Added retry logic for refreshShardMap
638e652
MissingNodeException bugfix
viv3kshukla-juspay 3f49188
Merge pull request #21 from gupta-ujjwal/feature/NodeRetryLogicForRef…
aravindgopall a21fa1b
Merge pull request #22 from imviv3kshukla/fix/MissingNodeException
aravindgopall 974d85e
throwing TimeoutException for timeouts
fc3b373
randomly choosing node for refreshShardMap
b7aea75
using fromException instead of displayException
22d8146
Merge pull request #23 from Candyman770/fix/timeoutException
aravindgopall 039a83d
changing NodeConnection to Pool of NodeConnection and taking Cluster …
shashitnak bc79b73
moving withResource call to the beginning of requestNode
shashitnak 8545c0e
moving NodeConnection HashMap in MVar and adding refreshCluster function
shashitnak 0ee0bf0
refreshShardMap is now updating both MVar's and removing refreshCluster
shashitnak 47613cf
dropping a NodeConnection from HashMap if it throws an exception in c…
shashitnak 4362e64
only adding new nodes to hashmap and not changing the old ones
shashitnak 4fd99de
saving a timestamp for last ShardMap refresh Time and creating entire…
shashitnak e22fbee
moving back to MVar's and fixing deadlock
shashitnak 883936f
moving Pipeline from Connection object to ClusterEnv
shashitnak 7427b2f
moving IORef inside Pool
shashitnak 1230e4c
changing NodeResource from data to newtype
shashitnak 8f27a40
addressing pr comments
shashitnak 5e9065c
fixing redudant import error due to previous change
shashitnak 7eed199
removing clusterConnect function
shashitnak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ import qualified Data.Time as Time | |
import Network.TLS (ClientParams) | ||
import qualified Network.Socket as NS | ||
import qualified Data.HashMap.Strict as HM | ||
import System.Random (randomRIO) | ||
import System.Environment (lookupEnv) | ||
import Data.Maybe (fromMaybe) | ||
import Text.Read (readMaybe) | ||
|
||
import qualified Database.Redis.ProtocolPipelining as PP | ||
import Database.Redis.Core(Redis, runRedisInternal, runRedisClusteredInternal) | ||
|
@@ -276,19 +280,22 @@ refreshShardMap (Cluster.Connection nodeConns _ _ _ _) = | |
|
||
refreshShardMapWithNodeConn :: [Cluster.NodeConnection] -> IO ShardMap | ||
refreshShardMapWithNodeConn [] = throwIO $ ClusterConnectError (Error "Couldn't refresh shardMap due to connection error") | ||
refreshShardMapWithNodeConn ((Cluster.NodeConnection ctx _ _) : xs) = do | ||
refreshShardMapWithNodeConn nodeConnsList = do | ||
selectedIdx <- randomRIO (0, (length nodeConnsList) - 1) | ||
let (Cluster.NodeConnection ctx _ _) = nodeConnsList !! selectedIdx | ||
pipelineConn <- PP.fromCtx ctx | ||
raceResult <- race (threadDelay (10^(3 :: Int))) (try $ refreshShardMapWithConn pipelineConn True) -- racing with delay of 1 ms | ||
envTimeout <- fromMaybe (10 ^ (3 :: Int)) . (>>= readMaybe) <$> lookupEnv "REDIS_CLUSTER_SLOTS_TIMEOUT" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we put these timeouts default in a single Config file within Hedis ? Having them distributed now is looking untidy. |
||
raceResult <- race (threadDelay envTimeout) (try $ refreshShardMapWithConn pipelineConn True) -- racing with delay of default 1 ms | ||
case raceResult of | ||
Left () -> do | ||
print $ "TimeoutForConnection " <> show ctx | ||
refreshShardMapWithNodeConn xs | ||
throwIO $ Cluster.TimeoutException "ClusterSlots Timeout" | ||
Right eiShardMapResp -> | ||
case eiShardMapResp of | ||
Right shardMap -> pure shardMap | ||
Left (err :: SomeException) -> do | ||
print $ "ShardMapRefreshError-" <> show err | ||
refreshShardMapWithNodeConn xs | ||
throwIO $ ClusterConnectError (Error "Couldn't refresh shardMap due to connection error") | ||
|
||
refreshShardMapWithConn :: PP.Connection -> Bool -> IO ShardMap | ||
refreshShardMapWithConn pipelineConn _ = do | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to match string in case of exception ? Can't we have a type of exception and pattern match it ?