Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-7286

ListenTCPRecord doesn't release port when stopping + terminating while running

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.12.0
    • None
    • None

    Description

      Reproduction steps

      1. Set 'ListenTCPRecord.Read Timeout' property to manageable value (like 120 second)
      2. Start ListenTCPRecord, listen on port XXX
      3. telnet HOST XXX (This will open and keep a connection to that port)
      4. Stop ListenTCPRecord while connection is open (After that, notice the 2 active threads on the processor)
      5. Terminate ListenTCPRecord
      6. Now any process (be it ListenTCPRecord or ListenTCP) that tries to listen on port XXX will report an "Address already in use" error

      Root cause
      ListenTCPRecord is trying to do cleanup in an @OnStopped method. The problem is that these methods won't be called while there are still running worker threads. When the processor is terminated, it eliminates the cleanup thread as well, so the cleanup never happens.
      ListenTCP for example doesn't exhibit this issue because its cleanup method is not annotated with @OnStopped but with @OnUnscheduled.

      Fix
      The solution is fairly simple: we just need to annotate the ListenTCPRecord cleanup method with @OnUnscheduled instead of @OnStopped.

      Attachments

        Issue Links

          Activity

            People

              tpalfy Tamas Palfy
              tpalfy Tamas Palfy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m