Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
f72956ec
Commit
f72956ec
authored
Jan 05, 2017
by
Marc Gravell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'deepakverma-innerexception'
parents
96aca8ee
9611b76f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
11 deletions
+69
-11
ConnectionFailedErrors.cs
StackExchange.Redis.Tests/ConnectionFailedErrors.cs
+17
-0
ConnectionMultiplexer.cs
...change.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
+13
-2
ExceptionFactory.cs
StackExchange.Redis/StackExchange/Redis/ExceptionFactory.cs
+38
-7
ServerEndPoint.cs
StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs
+1
-2
No files found.
StackExchange.Redis.Tests/ConnectionFailedErrors.cs
View file @
f72956ec
...
...
@@ -87,6 +87,23 @@ public void SocketFailureError()
}
}
#if DEBUG // needs AllowConnect, which is DEBUG only
[
Test
]
public
void
AbortOnConnectFailFalseConnectTimeoutError
()
{
string
name
,
password
;
GetAzureCredentials
(
out
name
,
out
password
);
var
options
=
new
ConfigurationOptions
();
options
.
EndPoints
.
Add
(
name
+
".redis.cache.windows.net"
);
options
.
Ssl
=
true
;
options
.
ConnectTimeout
=
0
;
options
.
Password
=
password
;
using
(
var
muxer
=
ConnectionMultiplexer
.
Connect
(
options
))
{
var
ex
=
Assert
.
Throws
<
RedisConnectionException
>(()
=>
muxer
.
GetDatabase
().
Ping
());
Assert
.
That
(
ex
.
Message
,
Does
.
Contain
(
"ConnectTimeout"
));
}
}
[
Test
]
public
void
CheckFailureRecovered
()
{
...
...
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
View file @
f72956ec
...
...
@@ -875,8 +875,12 @@ private static ConnectionMultiplexer ConnectImpl(Func<ConnectionMultiplexer> mul
{
task
.
ObserveErrors
();
if
(
muxer
.
RawConfig
.
AbortOnConnectFail
)
{
throw
ExceptionFactory
.
UnableToConnect
(
"Timeout"
);
{
throw
ExceptionFactory
.
UnableToConnect
(
"ConnectTimeout"
);
}
else
{
muxer
.
LastException
=
ExceptionFactory
.
UnableToConnect
(
"ConnectTimeout"
);
}
}
if
(!
task
.
Result
)
throw
ExceptionFactory
.
UnableToConnect
(
muxer
.
failureMessage
);
...
...
@@ -992,6 +996,9 @@ private void OnHeartbeat()
return
unchecked
(
Environment
.
TickCount
-
VolatileWrapper
.
Read
(
ref
lastHeartbeatTicks
))
/
1000
;
}
}
internal
Exception
LastException
{
get
;
set
;
}
internal
static
long
LastGlobalHeartbeatSecondsAgo
=>
unchecked
(
Environment
.
TickCount
-
VolatileWrapper
.
Read
(
ref
lastGlobalHeartbeatTicks
))
/
1000
;
internal
CompletionManager
UnprocessableCompletionManager
=>
unprocessableCompletionManager
;
...
...
@@ -1137,6 +1144,10 @@ public bool Configure(TextWriter log = null)
{
throw
new
TimeoutException
();
}
else
{
LastException
=
new
TimeoutException
(
"ConnectTimeout"
);
}
return
false
;
}
return
task
.
Result
;
...
...
StackExchange.Redis/StackExchange/Redis/ExceptionFactory.cs
View file @
f72956ec
...
...
@@ -74,38 +74,69 @@ internal static Exception MultiSlot(bool includeDetail, Message message)
if
(
includeDetail
)
AddDetail
(
ex
,
message
,
null
,
null
);
return
ex
;
}
internal
static
string
GetInnerMostExceptionMessage
(
Exception
e
)
{
if
(
e
==
null
)
{
return
""
;
}
else
{
while
(
e
.
InnerException
!=
null
)
{
e
=
e
.
InnerException
;
}
return
e
.
Message
;
}
}
internal
static
Exception
NoConnectionAvailable
(
bool
includeDetail
,
RedisCommand
command
,
Message
message
,
ServerEndPoint
server
,
ServerEndPoint
[]
serverSnapshot
)
{
string
s
=
GetLabel
(
includeDetail
,
command
,
message
);
string
commandLabel
=
GetLabel
(
includeDetail
,
command
,
message
);
if
(
server
!=
null
)
{
//if we already have the serverEndpoint for connection failure use that
//otherwise it would output state of all the endpoints
serverSnapshot
=
new
ServerEndPoint
[]
{
server
};
}
var
innerException
=
PopulateInnerExceptions
(
serverSnapshot
);
StringBuilder
exceptionmessage
=
new
StringBuilder
(
"No connection is available to service this operation: "
).
Append
(
commandLabel
);
string
innermostExceptionstring
=
GetInnerMostExceptionMessage
(
innerException
);
if
(!
string
.
IsNullOrEmpty
(
innermostExceptionstring
))
{
exceptionmessage
.
Append
(
"; "
).
Append
(
innermostExceptionstring
);
}
string
exceptionmessage
=
"No connection is available to service this operation: "
+
s
;
#if !CORE_CLR
if
(
includeDetail
)
{
exceptionmessage
+=
". "
+
ConnectionMultiplexer
.
GetThreadPoolAndCPUSummary
(
);
exceptionmessage
.
Append
(
"; "
).
Append
(
ConnectionMultiplexer
.
GetThreadPoolAndCPUSummary
()
);
}
#endif
var
ex
=
new
RedisConnectionException
(
ConnectionFailureType
.
UnableToResolvePhysicalConnection
,
exceptionmessage
,
GetServerSnapshotInnerExceptions
(
serverSnapshot
));
var
ex
=
new
RedisConnectionException
(
ConnectionFailureType
.
UnableToResolvePhysicalConnection
,
exceptionmessage
.
ToString
(),
innerException
);
if
(
includeDetail
)
{
AddDetail
(
ex
,
message
,
server
,
s
);
AddDetail
(
ex
,
message
,
server
,
commandLabel
);
}
return
ex
;
}
internal
static
Exception
GetServerSnapshot
InnerExceptions
(
ServerEndPoint
[]
serverSnapshot
)
internal
static
Exception
Populate
InnerExceptions
(
ServerEndPoint
[]
serverSnapshot
)
{
List
<
Exception
>
innerExceptions
=
new
List
<
Exception
>();
if
(
serverSnapshot
!=
null
)
{
if
(
serverSnapshot
.
Length
>
0
&&
serverSnapshot
[
0
].
Multiplexer
.
LastException
!=
null
)
{
innerExceptions
.
Add
(
serverSnapshot
[
0
].
Multiplexer
.
LastException
);
}
for
(
int
i
=
0
;
i
<
serverSnapshot
.
Length
;
i
++)
{
if
(
serverSnapshot
[
i
].
LastException
!=
null
)
...
...
StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs
View file @
f72956ec
...
...
@@ -101,8 +101,7 @@ internal Exception LastException
//check if subscription endpoint has a better lastexception
if
(
tmp2
!=
null
&&
tmp2
.
LastException
!=
null
)
{
var
failureType
=
tmp2
.
LastException
.
Data
[
"Redis-FailureType"
];
if
(
failureType
!=
null
&&
!
failureType
.
ToString
().
Equals
(
ConnectionFailureType
.
UnableToConnect
.
ToString
()))
if
(
tmp2
.
LastException
.
Data
.
Contains
(
"Redis-FailureType"
)
&&
!
tmp2
.
LastException
.
Data
[
"Redis-FailureType"
].
ToString
().
Equals
(
ConnectionFailureType
.
UnableToConnect
.
ToString
()))
{
return
tmp2
.
LastException
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment