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
47721b9a
Commit
47721b9a
authored
Aug 13, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reverse the lock work so we always add to the queue before writing
parent
0badeaef
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
27 deletions
+6
-27
Scripting.cs
StackExchange.Redis.Tests/Scripting.cs
+1
-1
PhysicalBridge.cs
StackExchange.Redis/PhysicalBridge.cs
+4
-20
PhysicalConnection.cs
StackExchange.Redis/PhysicalConnection.cs
+1
-6
No files found.
StackExchange.Redis.Tests/Scripting.cs
View file @
47721b9a
...
@@ -313,7 +313,7 @@ public void ScriptThrowsErrorInsideTransaction()
...
@@ -313,7 +313,7 @@ public void ScriptThrowsErrorInsideTransaction()
Assert
.
Equal
(
1L
,
a
.
Result
);
Assert
.
Equal
(
1L
,
a
.
Result
);
Assert
.
Equal
(
2L
,
c
.
Result
);
Assert
.
Equal
(
2L
,
c
.
Result
);
Assert
.
True
(
b
.
IsFaulted
);
Assert
.
True
(
QuickWait
(
b
).
IsFaulted
,
"should be faulted"
);
Assert
.
Single
(
b
.
Exception
.
InnerExceptions
);
Assert
.
Single
(
b
.
Exception
.
InnerExceptions
);
var
ex
=
b
.
Exception
.
InnerExceptions
.
Single
();
var
ex
=
b
.
Exception
.
InnerExceptions
.
Single
();
Assert
.
IsType
<
RedisServerException
>(
ex
);
Assert
.
IsType
<
RedisServerException
>(
ex
);
...
...
StackExchange.Redis/PhysicalBridge.cs
View file @
47721b9a
...
@@ -706,8 +706,8 @@ private void SelectDatabaseInsideWriteLock(PhysicalConnection connection, Messag
...
@@ -706,8 +706,8 @@ private void SelectDatabaseInsideWriteLock(PhysicalConnection connection, Messag
var
sel
=
connection
.
GetSelectDatabaseCommand
(
db
,
message
);
var
sel
=
connection
.
GetSelectDatabaseCommand
(
db
,
message
);
if
(
sel
!=
null
)
if
(
sel
!=
null
)
{
{
sel
.
WriteTo
(
connection
);
connection
.
EnqueueInsideWriteLock
(
sel
);
connection
.
EnqueueInsideWriteLock
(
sel
);
sel
.
WriteTo
(
connection
);
sel
.
SetRequestSent
();
sel
.
SetRequestSent
();
IncrementOpCount
();
IncrementOpCount
();
}
}
...
@@ -744,8 +744,8 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
...
@@ -744,8 +744,8 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
var
readmode
=
connection
.
GetReadModeCommand
(
isMasterOnly
);
var
readmode
=
connection
.
GetReadModeCommand
(
isMasterOnly
);
if
(
readmode
!=
null
)
if
(
readmode
!=
null
)
{
{
readmode
.
WriteTo
(
connection
);
connection
.
EnqueueInsideWriteLock
(
readmode
);
connection
.
EnqueueInsideWriteLock
(
readmode
);
readmode
.
WriteTo
(
connection
);
readmode
.
SetRequestSent
();
readmode
.
SetRequestSent
();
IncrementOpCount
();
IncrementOpCount
();
}
}
...
@@ -753,8 +753,8 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
...
@@ -753,8 +753,8 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
if
(
message
.
IsAsking
)
if
(
message
.
IsAsking
)
{
{
var
asking
=
ReusableAskingCommand
;
var
asking
=
ReusableAskingCommand
;
asking
.
WriteTo
(
connection
);
connection
.
EnqueueInsideWriteLock
(
asking
);
connection
.
EnqueueInsideWriteLock
(
asking
);
asking
.
WriteTo
(
connection
);
asking
.
SetRequestSent
();
asking
.
SetRequestSent
();
IncrementOpCount
();
IncrementOpCount
();
}
}
...
@@ -772,9 +772,8 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
...
@@ -772,9 +772,8 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
break
;
break
;
}
}
//connection.EnqueueInsideWriteLock(message);
message
.
WriteTo
(
connection
);
connection
.
EnqueueInsideWriteLock
(
message
);
connection
.
EnqueueInsideWriteLock
(
message
);
message
.
WriteTo
(
connection
);
message
.
SetRequestSent
();
message
.
SetRequestSent
();
IncrementOpCount
();
IncrementOpCount
();
...
@@ -798,21 +797,6 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
...
@@ -798,21 +797,6 @@ private WriteResult WriteMessageToServerInsideWriteLock(PhysicalConnection conne
}
}
return
WriteResult
.
Success
;
return
WriteResult
.
Success
;
}
}
catch
(
RedisCommandException
ex
)
{
Trace
(
"Write failed: "
+
ex
.
Message
);
message
.
Fail
(
ConnectionFailureType
.
InternalFailure
,
ex
,
null
);
this
.
CompleteSyncOrAsync
(
message
);
// this failed without actually writing; we're OK with that... unless there's a transaction
if
(
connection
?.
TransactionActive
==
true
)
{
// we left it in a broken state; need to kill the connection
connection
.
RecordConnectionFailed
(
ConnectionFailureType
.
ProtocolFailure
,
ex
);
return
WriteResult
.
WriteFailure
;
}
return
WriteResult
.
Success
;
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
Trace
(
"Write failed: "
+
ex
.
Message
);
Trace
(
"Write failed: "
+
ex
.
Message
);
...
...
StackExchange.Redis/PhysicalConnection.cs
View file @
47721b9a
...
@@ -457,7 +457,6 @@ internal void EnqueueInsideWriteLock(Message next)
...
@@ -457,7 +457,6 @@ internal void EnqueueInsideWriteLock(Message next)
lock
(
_writtenAwaitingResponse
)
lock
(
_writtenAwaitingResponse
)
{
{
_writtenAwaitingResponse
.
Enqueue
(
next
);
_writtenAwaitingResponse
.
Enqueue
(
next
);
if
(
_writtenAwaitingResponse
.
Count
==
1
)
Monitor
.
Pulse
(
_writtenAwaitingResponse
);
}
}
}
}
...
@@ -1271,11 +1270,7 @@ private void MatchResult(RawResult result)
...
@@ -1271,11 +1270,7 @@ private void MatchResult(RawResult result)
lock
(
_writtenAwaitingResponse
)
lock
(
_writtenAwaitingResponse
)
{
{
if
(
_writtenAwaitingResponse
.
Count
==
0
)
if
(
_writtenAwaitingResponse
.
Count
==
0
)
{
throw
new
InvalidOperationException
(
"Received response with no message waiting: "
+
result
.
ToString
());
// we could be racing with the writer, but this *really* shouldn't
// be even remotely close
Monitor
.
Wait
(
_writtenAwaitingResponse
,
500
);
}
msg
=
_writtenAwaitingResponse
.
Dequeue
();
msg
=
_writtenAwaitingResponse
.
Dequeue
();
}
}
...
...
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