Solr
  1. Solr
  2. SOLR-7635

bin/solr -e cloud can fail on MacOS

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.2
    • Fix Version/s: 5.3
    • Component/s: scripts and tools
    • Labels:
      None
    • Environment:

      Unix

      Description

      On MacOS:

      bin/solr -e cloud
      said:
      Please enter the port for node1 [8983]
      Oops! Looks like port 8983 is already being used by another process. Please choose a different port.

      Looking at the script, it uses:
      PORT_IN_USE=`lsof -Pni:$CLOUD_PORT`
      which gave the output:
      {{
      COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
      Google 365 upayavira 130u IPv6 0xab1d227df2e5a7db 0t0 TCP [::1]:49889->[::1]:8983 (ESTABLISHED)
      java 10889 upayavira 118u IPv6 0xab1d227df2e73ddb 0t0 TCP *:8983 (LISTEN)
      java 10889 upayavira 134u IPv6 0xab1d227df2e756db 0t0 TCP [::1]:8983->[::1]:49889 (ESTABLISHED)
      }}
      This was connections Google Chrome was attempting to make to Solr.

      Replacing the above line with this:

      PORT_IN_USE=`lsof -Pni:$CLOUD_PORT | grep LISTEN`

      resolved the issue. Very simple patch attached.

      1. SOLR-7635.patch
        1.0 kB
        Ramkumar Aiyengar
      2. SOLR-7635.patch
        1.0 kB
        Upayavira
      3. SOLR-7635.patch
        0.7 kB
        Upayavira

        Activity

        Hide
        Upayavira added a comment -

        A patch that covers non-cloud mode case too.

        Show
        Upayavira added a comment - A patch that covers non-cloud mode case too.
        Hide
        Shawn Heisey added a comment - - edited

        This is not exactly related to this specific issue, but I'm wondering ... what do we want to do in the Solr script if lsof is not installed on the machine? I would imagine that currently if lsof is not installed but the port IS already in use, that the script may try to start Solr anyway, and I'm not sure that the user would know why it doesn't work.

        Show
        Shawn Heisey added a comment - - edited This is not exactly related to this specific issue, but I'm wondering ... what do we want to do in the Solr script if lsof is not installed on the machine? I would imagine that currently if lsof is not installed but the port IS already in use, that the script may try to start Solr anyway, and I'm not sure that the user would know why it doesn't work.
        Hide
        Upayavira added a comment -

        If lsof doesn't exist, then we can't check for them, I'd say it is better to report no lsof and say "attempting to start", and let it fail with "port in use" if that happens. Alternatively, given we have Java to hand, a simple java class that attempts to connect to Solr wouldn't be too hard to write in this scenario.

        However, the point of this ticket is simply to fix a case I had where bin/solr start refused to start Solr even though it wasn't running. lsof was listing my browser's connection to Solr, rather than Solr listening. This patch will prevent that happening.

        Show
        Upayavira added a comment - If lsof doesn't exist, then we can't check for them, I'd say it is better to report no lsof and say "attempting to start", and let it fail with "port in use" if that happens. Alternatively, given we have Java to hand, a simple java class that attempts to connect to Solr wouldn't be too hard to write in this scenario. However, the point of this ticket is simply to fix a case I had where bin/solr start refused to start Solr even though it wasn't running. lsof was listing my browser's connection to Solr, rather than Solr listening. This patch will prevent that happening.
        Hide
        Ramkumar Aiyengar added a comment -

        Attached a revised patch without the need for the grep..

        Show
        Ramkumar Aiyengar added a comment - Attached a revised patch without the need for the grep..
        Hide
        ASF subversion and git services added a comment -

        Commit 1685296 from Ramkumar Aiyengar in branch 'dev/trunk'
        [ https://svn.apache.org/r1685296 ]

        SOLR-7635: Limit lsof port check in bin/solr to just listening ports

        Show
        ASF subversion and git services added a comment - Commit 1685296 from Ramkumar Aiyengar in branch 'dev/trunk' [ https://svn.apache.org/r1685296 ] SOLR-7635 : Limit lsof port check in bin/solr to just listening ports
        Hide
        ASF subversion and git services added a comment -

        Commit 1685298 from Ramkumar Aiyengar in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1685298 ]

        SOLR-7635: Limit lsof port check in bin/solr to just listening ports

        Show
        ASF subversion and git services added a comment - Commit 1685298 from Ramkumar Aiyengar in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1685298 ] SOLR-7635 : Limit lsof port check in bin/solr to just listening ports
        Hide
        Ramkumar Aiyengar added a comment -

        Thanks Upayavira!

        Show
        Ramkumar Aiyengar added a comment - Thanks Upayavira!
        Hide
        Shalin Shekhar Mangar added a comment -

        Bulk close for 5.3.0 release

        Show
        Shalin Shekhar Mangar added a comment - Bulk close for 5.3.0 release

          People

          • Assignee:
            Ramkumar Aiyengar
            Reporter:
            Upayavira
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development