Github user sarutak commented on a diff in the pull request:
https://github.com/apache/spark/pull/2019#discussion_r16728852
--- Diff:
core/src/main/scala/org/apache/spark/network/ConnectionManager.scala ---
@@ -334,17 +338,23 @@ private[spark] class ConnectionManager(
while (allKeys.hasNext) {
val key = allKeys.next()
try {
- if (! key.isValid) {
- logInfo("Key not valid ? " + key)
- throw new CancelledKeyException()
+ key.synchronized {
+ val connection = connectionsByKey.getOrElse(key, null)
+ if (key.channel.isInstanceOf[ServerSocketChannel] ||
+ connection != null && !connection.isClosed) {
+ if (!key.isValid) {
--- End diff --
I don't think we cannot merge 2 condition because L343-344 wants to check
connection is closed by another thread (it's not always abnormal case.
sometimes happens). and L345 wants to check channel is accidentally closed.
Usually, if channel is closed, connection should null. I'd like to detect
irregular case.
And, I check for ServerSocketChannel because key is related to
ServerSocketChannel, connection is always null and enters infinite loop.
---
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]