Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-942

Infinite loop flushing to broken pipe

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.7
    • Fix Version/s: 2.0.8
    • Component/s: None
    • Labels:
      None

      Description

      Every once in a while (in production only, of course), a couple of threads will go off into the weeds, consuming 100% CPU, and never come back. They're sitting in an infinite loop that looks something like this:

      • We're chugging merrily along in the main processing loop (AbstractPollingIoProcessor.java:1070)
      • Decide to flush the single session in flushingSessions (AbstractPollingIoProcessor.java:773, :1129)
      • According to "SessionState state = getState(session)", the session is OPENED, which I think is a lie, and perhaps the root of the problem.
      • Enter "flushNow" (AbstractPollingIoProcessor.java:821, :789, :1129)
      • Begin processing a queued message (AbstractPollingIoProcessor.java:861, :789, :1129)
      • Try to write out the message in writeBuffer (AbstractPollingIoProcessor.java:931, :861, :789, :1129)
      • Catch an IOException ("Broken pipe") in writeBuffer (AbstractPollingIoProcessor.java:935, :861, :789, :1129), call "session.close(true)"
      • Next time around the loop at (AbstractPollingIoProcessor.java:1070), the session is put back in flushingSessions, because apparently the session is still writable (liar!) (AbstractPollingIoProcessor.java:671, :653, :1124)
      • Repeat, Ad Infinitum!

      The suggested fix, courtesy Emmanuel Lecharny, is:
      add this line in the AbstractPollingIoProcessor
      class, line 927 :

                  try {
                      localWrittenBytes = write(session, buf, length);
                  } catch (IOException ioe) {
                      // We have had an issue while trying to send data to the
                      // peer : let's close the session.
                      buf.free();
                      session.close(true);
      
                      destroy(session);  // <<<<<<<<<<<<<<<<<---- This line
      
                      return 0;
                  }
      

        Activity

        Hide
        elecharny Emmanuel Lecharny added a comment -

        Fixed in commit 5955d7281936d97f5ca39d9619692f05e48140d9

        Show
        elecharny Emmanuel Lecharny added a comment - Fixed in commit 5955d7281936d97f5ca39d9619692f05e48140d9

          People

          • Assignee:
            Unassigned
            Reporter:
            allpowerful32 Joshua Warner
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development