Solr
  1. Solr
  2. SOLR-590

Limitation in pgrep on Linux platform breaks script-utils fixUser

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Linux 2.6.18-53.1.14.el5 #1 SMP Wed Mar 5 11:37:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
      procps-3.2.7-8.1.el5

      Description

      The fixUser function in script-utils uses two methods to determine the username of the parent process (oldwhoami). If the first method fails for certain reasons it will fallback to the second method. For most people the first method will succeed but I know that in my particular installation the first method fails so I need the second method to succeed. Unfortunately, that fallback method doesn't work because it uses pgrep to lookup the current script's name and on my Linux 2.6.18 platform pgrep is limited to 15 characters. The names of many scripts in the SOLR distribution are longer than that, causing pgrep to return nothing and the subsequent ps invocation to fail with an error:

      ERROR: List of process IDs must follow -p.

      You can easily reproduce that behaviour with

      /app/solr/solr/bin/snappuller-enable < /dev/null

      The redirection of stdin from /dev/null causes fixUser to fallback to the second method but there are other, more realistic scenarios in which the fallback happens, like

      ssh jetty@host /app/solr/solr/bin/snappuller-enable

      The fix is to use the -f option which causes pgrep to compare the full path of the executable. Interestingly, that method is not subject to the 15 character length limit. The limit is not actually enforced by jetty but rather by the procfs file system of the linux kernel. If you look at /proc/*/stat you will notice that the second column is limited to 15 characters.

      1. fixUser.patch
        0.4 kB
        Hannes Schmidt

        Activity

        Hide
        Hannes Schmidt added a comment -

        Changing priority to minor.

        Show
        Hannes Schmidt added a comment - Changing priority to minor.
        Hide
        Hannes Schmidt added a comment -

        Attaching patch.

        Show
        Hannes Schmidt added a comment - Attaching patch.
        Hide
        Bill Au added a comment -

        Patch commited and CHANGES.txt updated. Thanks Hannes.

        Sending CHANGES.txt
        Sending src/scripts/scripts-util
        Transmitting file data ..
        Committed revision 663089.

        Show
        Bill Au added a comment - Patch commited and CHANGES.txt updated. Thanks Hannes. Sending CHANGES.txt Sending src/scripts/scripts-util Transmitting file data .. Committed revision 663089.

          People

          • Assignee:
            Bill Au
            Reporter:
            Hannes Schmidt
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development