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
0c7f531a
Commit
0c7f531a
authored
Aug 20, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moar logging on CheckForStaleConnections
parent
83a046eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+13
-3
SocketManager.Poll.cs
...kExchange.Redis/StackExchange/Redis/SocketManager.Poll.cs
+13
-2
SocketManager.cs
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
+1
-1
No files found.
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
0c7f531a
...
@@ -158,11 +158,16 @@ public void Flush()
...
@@ -158,11 +158,16 @@ public void Flush()
Interlocked
.
Exchange
(
ref
lastWriteTickCount
,
Environment
.
TickCount
);
Interlocked
.
Exchange
(
ref
lastWriteTickCount
,
Environment
.
TickCount
);
}
}
}
}
public
void
RecordConnectionFailed
(
ConnectionFailureType
failureType
,
Exception
innerException
=
null
,
[
CallerMemberName
]
string
origin
=
null
)
public
void
RecordConnectionFailed
(
ConnectionFailureType
failureType
,
Exception
innerException
=
null
,
[
CallerMemberName
]
string
origin
=
null
)
{
SocketManager
.
ManagerState
mgrState
=
SocketManager
.
ManagerState
.
CheckForStaleConnections
;
RecordConnectionFailed
(
failureType
,
ref
mgrState
,
innerException
,
origin
);
}
public
void
RecordConnectionFailed
(
ConnectionFailureType
failureType
,
ref
SocketManager
.
ManagerState
managerState
,
Exception
innerException
=
null
,
[
CallerMemberName
]
string
origin
=
null
)
{
{
IdentifyFailureType
(
innerException
,
ref
failureType
);
IdentifyFailureType
(
innerException
,
ref
failureType
);
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_OnInternalError
;
if
(
failureType
==
ConnectionFailureType
.
InternalFailure
)
OnInternalError
(
innerException
,
origin
);
if
(
failureType
==
ConnectionFailureType
.
InternalFailure
)
OnInternalError
(
innerException
,
origin
);
// stop anything new coming in...
// stop anything new coming in...
...
@@ -170,6 +175,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
...
@@ -170,6 +175,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
bool
isCurrent
;
bool
isCurrent
;
PhysicalBridge
.
State
oldState
;
PhysicalBridge
.
State
oldState
;
int
@in
=
-
1
,
ar
=
-
1
;
int
@in
=
-
1
,
ar
=
-
1
;
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_OnDisconnected
;
bridge
.
OnDisconnected
(
failureType
,
this
,
out
isCurrent
,
out
oldState
);
bridge
.
OnDisconnected
(
failureType
,
this
,
out
isCurrent
,
out
oldState
);
if
(
oldState
==
PhysicalBridge
.
State
.
ConnectedEstablished
)
if
(
oldState
==
PhysicalBridge
.
State
.
ConnectedEstablished
)
{
{
...
@@ -182,6 +188,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
...
@@ -182,6 +188,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
if
(
isCurrent
&&
Interlocked
.
CompareExchange
(
ref
failureReported
,
1
,
0
)
==
0
)
if
(
isCurrent
&&
Interlocked
.
CompareExchange
(
ref
failureReported
,
1
,
0
)
==
0
)
{
{
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_ReportFailure
;
int
now
=
Environment
.
TickCount
,
lastRead
=
Thread
.
VolatileRead
(
ref
lastReadTickCount
),
lastWrite
=
Thread
.
VolatileRead
(
ref
lastWriteTickCount
),
int
now
=
Environment
.
TickCount
,
lastRead
=
Thread
.
VolatileRead
(
ref
lastReadTickCount
),
lastWrite
=
Thread
.
VolatileRead
(
ref
lastWriteTickCount
),
lastBeat
=
Thread
.
VolatileRead
(
ref
lastBeatTickCount
);
lastBeat
=
Thread
.
VolatileRead
(
ref
lastBeatTickCount
);
int
unansweredRead
=
Thread
.
VolatileRead
(
ref
firstUnansweredWriteTickCount
);
int
unansweredRead
=
Thread
.
VolatileRead
(
ref
firstUnansweredWriteTickCount
);
...
@@ -232,10 +239,12 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
...
@@ -232,10 +239,12 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
ex
.
Data
[
"Redis-"
+
kv
.
Item1
]
=
kv
.
Item2
;
ex
.
Data
[
"Redis-"
+
kv
.
Item1
]
=
kv
.
Item2
;
}
}
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_OnConnectionFailed
;
bridge
.
OnConnectionFailed
(
this
,
failureType
,
ex
);
bridge
.
OnConnectionFailed
(
this
,
failureType
,
ex
);
}
}
// cleanup
// cleanup
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_FailOutstanding
;
lock
(
outstanding
)
lock
(
outstanding
)
{
{
bridge
.
Trace
(
outstanding
.
Count
!=
0
,
"Failing outstanding messages: "
+
outstanding
.
Count
);
bridge
.
Trace
(
outstanding
.
Count
!=
0
,
"Failing outstanding messages: "
+
outstanding
.
Count
);
...
@@ -249,6 +258,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
...
@@ -249,6 +258,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
}
}
// burn the socket
// burn the socket
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_ShutdownSocket
;
var
socketManager
=
multiplexer
.
SocketManager
;
var
socketManager
=
multiplexer
.
SocketManager
;
if
(
socketManager
!=
null
)
socketManager
.
Shutdown
(
socketToken
);
if
(
socketManager
!=
null
)
socketManager
.
Shutdown
(
socketToken
);
}
}
...
@@ -1045,7 +1055,7 @@ RawResult TryParseResult(byte[] buffer, ref int offset, ref int count)
...
@@ -1045,7 +1055,7 @@ RawResult TryParseResult(byte[] buffer, ref int offset, ref int count)
partial
void
DebugEmulateStaleConnection
(
ref
int
firstUnansweredWrite
);
partial
void
DebugEmulateStaleConnection
(
ref
int
firstUnansweredWrite
);
public
void
CheckForStaleConnection
()
public
void
CheckForStaleConnection
(
ref
SocketManager
.
ManagerState
managerState
)
{
{
int
firstUnansweredWrite
;
int
firstUnansweredWrite
;
firstUnansweredWrite
=
Thread
.
VolatileRead
(
ref
firstUnansweredWriteTickCount
);
firstUnansweredWrite
=
Thread
.
VolatileRead
(
ref
firstUnansweredWriteTickCount
);
...
@@ -1056,7 +1066,7 @@ public void CheckForStaleConnection()
...
@@ -1056,7 +1066,7 @@ public void CheckForStaleConnection()
if
(
firstUnansweredWrite
!=
0
&&
(
now
-
firstUnansweredWrite
)
>
this
.
multiplexer
.
RawConfig
.
ResponseTimeout
)
if
(
firstUnansweredWrite
!=
0
&&
(
now
-
firstUnansweredWrite
)
>
this
.
multiplexer
.
RawConfig
.
ResponseTimeout
)
{
{
this
.
RecordConnectionFailed
(
ConnectionFailureType
.
SocketFailure
,
origin
:
"CheckForStaleConnection"
);
this
.
RecordConnectionFailed
(
ConnectionFailureType
.
SocketFailure
,
ref
managerState
,
origin
:
"CheckForStaleConnection"
);
}
}
}
}
}
}
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.Poll.cs
View file @
0c7f531a
...
@@ -158,13 +158,23 @@ internal enum ManagerState
...
@@ -158,13 +158,23 @@ internal enum ManagerState
ExecuteSelect
,
ExecuteSelect
,
ExecuteSelectComplete
,
ExecuteSelectComplete
,
CheckForStaleConnections
,
CheckForStaleConnections
,
RecordConnectionFailed_OnInternalError
,
RecordConnectionFailed_OnDisconnected
,
RecordConnectionFailed_ReportFailure
,
RecordConnectionFailed_OnConnectionFailed
,
RecordConnectionFailed_FailOutstanding
,
RecordConnectionFailed_ShutdownSocket
,
CheckForStaleConnectionsDone
,
EnqueueRead
,
EnqueueRead
,
EnqueueError
,
EnqueueError
,
EnqueueReadFallback
,
EnqueueReadFallback
,
RequestAssistance
,
RequestAssistance
,
ProcessQueues
,
ProcessQueues
,
ProcessReadQueue
,
ProcessReadQueue
,
ProcessErrorQueue
,
ProcessErrorQueue
,
}
}
internal
ManagerState
State
internal
ManagerState
State
{
{
...
@@ -294,9 +304,10 @@ private void ReadImpl()
...
@@ -294,9 +304,10 @@ private void ReadImpl()
}
}
else
else
{
{
s
.
CheckForStaleConnection
();
s
.
CheckForStaleConnection
(
ref
managerState
);
}
}
}
}
managerState
=
ManagerState
.
CheckForStaleConnectionsDone
;
}
}
else
else
{
{
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
0c7f531a
...
@@ -40,7 +40,7 @@ internal partial interface ISocketCallback
...
@@ -40,7 +40,7 @@ internal partial interface ISocketCallback
void
StartReading
();
void
StartReading
();
// check for write-read timeout
// check for write-read timeout
void
CheckForStaleConnection
();
void
CheckForStaleConnection
(
ref
SocketManager
.
ManagerState
state
);
bool
IsDataAvailable
{
get
;
}
bool
IsDataAvailable
{
get
;
}
}
}
...
...
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