Github user sarutak commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2019#discussion_r16736248
  
    --- 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 separate !key.isValid from the rest intentionally.
    When connection is null or connection is closed, !key.isValid is true 
because connection is closed by another thread calling Connection#close and 
it's not the case we should log.
    
    If key.isValid is false, even if connection is not closed, it's abnormal 
case.
    
    Anyway, we (including other committer/contributor) should discuss how we 
treat this issue.


---
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]

Reply via email to