Github user sarutak commented on a diff in the pull request:
https://github.com/apache/spark/pull/2019#discussion_r16632233
--- Diff: core/src/main/scala/org/apache/spark/network/Connection.scala ---
@@ -263,14 +282,20 @@ class SendingConnection(val address:
InetSocketAddress, selector_ : Selector,
val DEFAULT_INTEREST = SelectionKey.OP_READ
+ var alreadyReading = false
+
override def registerInterest() {
// Registering read too - does not really help in most cases, but for
some
// it does - so let us keep it for now.
- changeConnectionKeyInterest(SelectionKey.OP_WRITE | DEFAULT_INTEREST)
+ changeConnectionKeyInterest(
+ SelectionKey.OP_WRITE | (if (!alreadyReading) {
+ alreadyReading = true
+ DEFAULT_INTEREST
+ } else { 0 }))
--- End diff --
Yes, we use blocking IO.
And I had a misunderstanding. SocketChannel#read blocks the other thread
which try to call SocketChannel#read on the same instance so unregistering
OP_READ is wrong.
So, we should resolve race condition using another way because a thread
registering OP_READ can call SocketChannel#close in SendingConnection#read
during a thread registering OP_WRITE calls SocketChannel#write in
SendingConnection#write.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]