Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9046

solr.cmd wrongly assumes Jetty will always listen on 0.0.0.0

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5
    • Fix Version/s: 5.5.1, 6.0.1, 6.1, 7.0
    • Component/s: Server
    • Labels:
      None
    • Environment:

      Windows

    • Flags:
      Patch

      Description

      The Windows solr.cmd script makes the (incorrect) assumption that Solr will always be listening on 0.0.0.0 (all interfaces). When you change the interface
      address, say to 127.0.0.1, then the status and stop commands will fail.

      This patch adds a property in solr.in.cmd, which is passed to SOLR_OPTS as -Djetty.host, and replaces the instances of 0.0.0.0 in solr.cmd.

      The patch includes some changes in the netstat logic used in solr.cmd to find the correct Solr process(es).

      Tested on Solr 5.5 on Windows 7 and 10.

      Note: Untested on Solr 6. Currently using Solr 5.5

      1. SOLR-9046.patch
        7 kB
        Uwe Schindler
      2. SOLR-9046.patch
        9 kB
        Uwe Schindler
      3. SOLR-9046.patch
        9 kB
        Uwe Schindler
      4. SOLR-9046.patch
        10 kB
        Uwe Schindler
      5. SOLR-9045.patch
        7 kB
        Bram Van Dam

        Activity

        Hide
        anshumg Anshum Gupta added a comment -

        Can someone review and commit this? I would have done this myself but 'windows'.

        Show
        anshumg Anshum Gupta added a comment - Can someone review and commit this? I would have done this myself but 'windows'.
        Hide
        thelabdude Timothy Potter added a comment -

        I'll take up it Anshum Gupta ... I'm spinning up a Windows box in EC2 today anyway.

        Show
        thelabdude Timothy Potter added a comment - I'll take up it Anshum Gupta ... I'm spinning up a Windows box in EC2 today anyway.
        Hide
        anshumg Anshum Gupta added a comment -

        Thanks Tim!

        Show
        anshumg Anshum Gupta added a comment - Thanks Tim!
        Hide
        thetaphi Uwe Schindler added a comment -

        Hi,
        I patched my checkout (master) locally. I am already testing (including all "bad" things like whitespace in path name). There are two thing that might not work - I am checking this, too:

        • It assumes that JETTY_HOST is an ip address. You can always also give a hostname. It should be documented in the new solr.cmd.in, that you have to use an IP address
        • It might not work with IPv6. As I am working in an IPv6 environment - IPv4 works, but is not preferred here anymore, I will report on bugs, too.
        Show
        thetaphi Uwe Schindler added a comment - Hi, I patched my checkout (master) locally. I am already testing (including all "bad" things like whitespace in path name). There are two thing that might not work - I am checking this, too: It assumes that JETTY_HOST is an ip address. You can always also give a hostname. It should be documented in the new solr.cmd.in, that you have to use an IP address It might not work with IPv6. As I am working in an IPv6 environment - IPv4 works, but is not preferred here anymore, I will report on bugs, too.
        Hide
        thetaphi Uwe Schindler added a comment - - edited

        OK status:
        This works correct for starting up, but fails on stopping with Solr bound to IPv6 - it always tells you that it cannot find a process - I had to kill Solr on my own. The problem is the regular expression / find pattern. I'll try to fix it (first understand what Bram's changes around there mean).

        Quick test is:

        set SOLR_JETTY_HOST=[::1]
        

        The Server starts up correctly and can be accessed with curl and web browser.

        Show
        thetaphi Uwe Schindler added a comment - - edited OK status: This works correct for starting up, but fails on stopping with Solr bound to IPv6 - it always tells you that it cannot find a process - I had to kill Solr on my own. The problem is the regular expression / find pattern. I'll try to fix it (first understand what Bram's changes around there mean). Quick test is: set SOLR_JETTY_HOST=[::1] The Server starts up correctly and can be accessed with curl and web browser.
        Hide
        thetaphi Uwe Schindler added a comment -

        The reason why it does not work is the way how it splits the port number from the address. It looks like this here:

          TCP    [::1]:8983             [::]:0                 LISTEN         5116
        
        Show
        thetaphi Uwe Schindler added a comment - The reason why it does not work is the way how it splits the port number from the address. It looks like this here: TCP [::1]:8983 [::]:0 LISTEN 5116
        Hide
        thetaphi Uwe Schindler added a comment -

        Otherwise patch looks OK. I just added a comment in solr.cmd.in to tell user to use IP address. Otherwise one may use "localhost" as SOLR_JETTY_HOST.

        Show
        thetaphi Uwe Schindler added a comment - Otherwise patch looks OK. I just added a comment in solr.cmd.in to tell user to use IP address. Otherwise one may use "localhost" as SOLR_JETTY_HOST.
        Hide
        thetaphi Uwe Schindler added a comment -

        Here is the updated patch with the additional comment in solr.cmd.in.

        Show
        thetaphi Uwe Schindler added a comment - Here is the updated patch with the additional comment in solr.cmd.in.
        Hide
        thetaphi Uwe Schindler added a comment - - edited

        New patch that works with IPv6. The trick is actually a simplification: Instead of trying to split host name and port, we keep them together (so we spare one "FOR /F" and just compare the whole host:port token).

        I tried with IPv4 addresses and IPv6 addresses and both variants "solr stop -all" and "solr stop -p 8983".

        Show
        thetaphi Uwe Schindler added a comment - - edited New patch that works with IPv6. The trick is actually a simplification: Instead of trying to split host name and port, we keep them together (so we spare one "FOR /F" and just compare the whole host:port token). I tried with IPv4 addresses and IPv6 addresses and both variants "solr stop -all" and "solr stop -p 8983".
        Hide
        thetaphi Uwe Schindler added a comment -

        Small documentation updates.

        Show
        thetaphi Uwe Schindler added a comment - Small documentation updates.
        Hide
        thelabdude Timothy Potter added a comment -

        Uwe Schindler do you want to commit this one to 5.5.1 for us? I picked it up to help out Anshum, but looks as though you have a better handle on the code changes and testing than I do If so please re-assign to yourself. Thanks.

        Show
        thelabdude Timothy Potter added a comment - Uwe Schindler do you want to commit this one to 5.5.1 for us? I picked it up to help out Anshum, but looks as though you have a better handle on the code changes and testing than I do If so please re-assign to yourself. Thanks.
        Hide
        thetaphi Uwe Schindler added a comment -

        Timothy, you wrote the original code - I think? Does it look correct for you? The "FOR /F" pattern with implicit variable names for tokens is just horrible Whoever invented this syntax should be shot by the Unicode Policeman.

        Show
        thetaphi Uwe Schindler added a comment - Timothy, you wrote the original code - I think? Does it look correct for you? The "FOR /F" pattern with implicit variable names for tokens is just horrible Whoever invented this syntax should be shot by the Unicode Policeman.
        Hide
        thetaphi Uwe Schindler added a comment -

        New patch. I missed to fix "solr -i" and the startup check. Now all usages are fixed.

        I think it is ready. It would still be good if somebody would review the variable name disaster!

        Show
        thetaphi Uwe Schindler added a comment - New patch. I missed to fix "solr -i" and the startup check. Now all usages are fixed. I think it is ready. It would still be good if somebody would review the variable name disaster!
        Hide
        thetaphi Uwe Schindler added a comment -

        I will now go to bed and I will commit this tomorrow morning to master, 6.x and 5.0.

        As I am now familar with the "FOR /F" logic, I may also be able to fix SOLR-8689.

        Show
        thetaphi Uwe Schindler added a comment - I will now go to bed and I will commit this tomorrow morning to master, 6.x and 5.0. As I am now familar with the "FOR /F" logic, I may also be able to fix SOLR-8689 .
        Hide
        anshumg Anshum Gupta added a comment - - edited

        Thanks Uwe. I believe you meant 5x and 5.5 instead of 5.0.

        Show
        anshumg Anshum Gupta added a comment - - edited Thanks Uwe. I believe you meant 5x and 5.5 instead of 5.0.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 3e6de6059ff8e42731e6acd52623e4f5d3e23fca in lucene-solr's branch refs/heads/master from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3e6de60 ]

        SOLR-9046: Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0

        Show
        jira-bot ASF subversion and git services added a comment - Commit 3e6de6059ff8e42731e6acd52623e4f5d3e23fca in lucene-solr's branch refs/heads/master from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3e6de60 ] SOLR-9046 : Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 9e34d3137f6b5a90a207c86b88cdd6ba17f0553e in lucene-solr's branch refs/heads/branch_6x from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=9e34d31 ]

        SOLR-9046: Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0

        Show
        jira-bot ASF subversion and git services added a comment - Commit 9e34d3137f6b5a90a207c86b88cdd6ba17f0553e in lucene-solr's branch refs/heads/branch_6x from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=9e34d31 ] SOLR-9046 : Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 95c985be0aed654a0bc293b72f75270603130f75 in lucene-solr's branch refs/heads/branch_5_5 from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=95c985b ]

        SOLR-9046: Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0

        1. Conflicts:
        2. solr/CHANGES.txt
        Show
        jira-bot ASF subversion and git services added a comment - Commit 95c985be0aed654a0bc293b72f75270603130f75 in lucene-solr's branch refs/heads/branch_5_5 from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=95c985b ] SOLR-9046 : Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0 Conflicts: solr/CHANGES.txt
        Hide
        thetaphi Uwe Schindler added a comment -

        I committed/cherrypicked the patch:

        • master
        • branch_6x
        • branch_5_5
        Show
        thetaphi Uwe Schindler added a comment - I committed/cherrypicked the patch: master branch_6x branch_5_5
        Hide
        thetaphi Uwe Schindler added a comment -

        Sorry, of course I committed to:

        • master
        • 6.x
        • 5.5
        Show
        thetaphi Uwe Schindler added a comment - Sorry, of course I committed to: master 6.x 5.5
        Hide
        thetaphi Uwe Schindler added a comment -

        I did not commit to 5.x branch, because this one was declared "dead" - only 5.5 is alive.

        Show
        thetaphi Uwe Schindler added a comment - I did not commit to 5.x branch, because this one was declared "dead" - only 5.5 is alive.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 391872065980bda690e61ee8757eefedc722e2fe in lucene-solr's branch refs/heads/branch_5x from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3918720 ]

        SOLR-9046: Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0

        1. Conflicts:
        2. solr/CHANGES.txt
        Show
        jira-bot ASF subversion and git services added a comment - Commit 391872065980bda690e61ee8757eefedc722e2fe in lucene-solr's branch refs/heads/branch_5x from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3918720 ] SOLR-9046 : Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0 Conflicts: solr/CHANGES.txt
        Hide
        thetaphi Uwe Schindler added a comment -

        I just noticed that all of you also backported to 5.x branch. So I cherry-picked the commit, too (from 5.5 to not conflict changes again)

        Show
        thetaphi Uwe Schindler added a comment - I just noticed that all of you also backported to 5.x branch. So I cherry-picked the commit, too (from 5.5 to not conflict changes again)
        Hide
        bvd Bram Van Dam added a comment -

        Thanks for these fixes and the commit. Just tested your changes on our setup and everything seems to work.

        Windows's netstat doesn't have an option to only display listening processes, which is why I added the 'find ":0 "'. Without that extra constraint, the stop process would try to shoot down internet explorer when I was using the admin UI Whoops!

        Show
        bvd Bram Van Dam added a comment - Thanks for these fixes and the commit. Just tested your changes on our setup and everything seems to work. Windows's netstat doesn't have an option to only display listening processes, which is why I added the 'find ":0 "'. Without that extra constraint, the stop process would try to shoot down internet explorer when I was using the admin UI Whoops!
        Hide
        hossman Hoss Man added a comment -

        Manually correcting fixVersion per Step #S5 of LUCENE-7271

        Show
        hossman Hoss Man added a comment - Manually correcting fixVersion per Step #S5 of LUCENE-7271
        Hide
        steve_rowe Steve Rowe added a comment -

        Reopening to backport to 6.0.1.

        Show
        steve_rowe Steve Rowe added a comment - Reopening to backport to 6.0.1.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 36c12041989d0be73b933b9454a12d3827d97282 in lucene-solr's branch refs/heads/branch_6_0 from Uwe Schindler
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=36c1204 ]

        SOLR-9046: Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0

        Show
        jira-bot ASF subversion and git services added a comment - Commit 36c12041989d0be73b933b9454a12d3827d97282 in lucene-solr's branch refs/heads/branch_6_0 from Uwe Schindler [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=36c1204 ] SOLR-9046 : Fix solr.cmd that wrongly assumes Jetty will always listen on 0.0.0.0
        Hide
        steve_rowe Steve Rowe added a comment -

        Bulk close issues included in the 6.0.1 release.

        Show
        steve_rowe Steve Rowe added a comment - Bulk close issues included in the 6.0.1 release.

          People

          • Assignee:
            thetaphi Uwe Schindler
            Reporter:
            bvd Bram Van Dam
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development