Skip to content
This repository has been archived by the owner on Aug 6, 2022. It is now read-only.

Fix race condition in wait-for-solr.sh #311

Merged

Conversation

jeetchris
Copy link
Contributor

Solve #310.

Script is failing to detect Solr instance as alive due to a race condition between two commands in a pipe.

grep -q succeeds and exits early, causing the still-writing wget to fail to write its stdout to the pipe, and the overall pipeline to fail.

Solution is:

replacing the grep part of the pipeline with just: grep -i solr >/dev/null

I tested it for Solr 8.5.1, under Mac and docker-machine only.

Issue can be reproduced (depending on the environment), using this docker-compose.yml file.

version: '3'
services:
  # Solr instance
  solr:
    image: solr:8.5.1
    ports:
      - 8983:8983
  # Should detect Solr running successfully
  solr-success:
    image: solr:8.5.1
    command: bash -c "wait-for-solr.sh --solr-url http://solr:8981"
  # Should not detect Solr, since port is wrong
  solr-fail:
    image: solr:8.5.1
    command: bash -c "wait-for-solr.sh --solr-url http://solr:8980"

Script is failing to detect Solr instance as alive due to a race
condition between two commands in a pipe.

`grep -q` succeeds and exits early, causing the still-writing `wget` to
fail to write its stdout to the pipe, and the overall pipeline to fail.
@makuk66 makuk66 self-requested a review May 8, 2020 10:21
Copy link
Contributor

@makuk66 makuk66 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Try running bash tools/update.sh; that should fill in the copies in the version directories for you, then you can add those to the PR too. (Today it shouldn't happen, but sometimes if you try that it discovers a new version and adds that, which should be a separate PR anyway, and you typically want to leave to the maintainers).

@jeetchris
Copy link
Contributor Author

@makuk66 Thank you, I ran the command and committed the result.
No new Solr version was found apparently.
Tell me if you prefer that I combine both commits into one.

@makuk66 makuk66 merged commit fc6b0cb into docker-solr:master May 8, 2020
@makuk66
Copy link
Contributor

makuk66 commented May 8, 2020

Great stuff -- thanks!

@jeetchris jeetchris deleted the issue-310-fix-wait-for-solr-script branch May 9, 2020 04:29
@jeetchris jeetchris restored the issue-310-fix-wait-for-solr-script branch May 9, 2020 04:30
janhoy added a commit to cominvent/docker-solr that referenced this pull request May 10, 2020
ncreuschling added a commit to dkd/docker-solr that referenced this pull request Oct 20, 2020
* 'master' of https://github.com/docker-solr/docker-solr:
  Upgrade to Solr 8.6.3 (docker-solr#351)
  Bashbrew link changed
  Upgrading to 8.6.2 (docker-solr#344)
  Add a link to release docs
  Add Solr 8.6.1
  Add Solr 8.6.0 (docker-solr#336)
  Add github user for Apache Solr project
  Upgrade to 8.5.2
  Remove misleading documentation about download server in Europe
  Added new key
  Add the jattach tool (docker-solr#321)
  Add gsed to mac requirement. Needed to build docs repo
  Update maintainer information (docker-solr#313)
  Make solr-create more stable. Follow-up fix similar to docker-solr#311 (docker-solr#312)
  Fix race condition in wait-for-solr.sh (docker-solr#311)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants