Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log lines are sometimes dropped #237

Closed
mkenigs opened this issue Aug 22, 2024 · 2 comments
Closed

Log lines are sometimes dropped #237

mkenigs opened this issue Aug 22, 2024 · 2 comments
Labels
bug Something isn't working done Done, awaiting release

Comments

@mkenigs
Copy link
Contributor

mkenigs commented Aug 22, 2024

If a service logs something immediately before exiting, that log line isn't always reported by process-compose process logs. Sometimes the line is reported, so it seems there is a race condition on service exit. I saw this when running on an x86_64-linux machine that was under some resource load; it didn't seem to happen when not under load.

I used the following script to pinpoint the issue. It starts a service that echos 1, sleeps briefly, and then echos 2 right before exiting. It then checks the logs for the service after waiting longer than the service should take to exit. If it doesn't find the additional log line (2), it sleeps an additional 10 seconds just to ensure it's not checking for logs before the service actually exits, and then it prints the logs.

In 20 runs (when the system was under load), the script would consistently print logs at least once that didn't contain 2.

If I add a sleep .1 after echo 2, I never see the 2 log line being dropped.

#!/usr/bin/env bash

set -euo pipefail

cat << EOF > process-compose.yml
version: "0.5"
log_level: debug

processes:
  sleep:
    command: "sleep 100"
  echo:
    command: |
      echo 1
      sleep .1
      echo 2
EOF

process-compose up -u pc.sock -L pc.log --tui=false >/dev/null 2>&1 &

# make sure process-compose has started
for i in {1..5}; do
  if process-compose process list -u pc.sock 2>/dev/null | grep sleep >/dev/null; then
    break;
  fi
  sleep .1
done
if [ "$i" == 5 ]; then
  echo "didn't start"
  exit 1
fi

sleep .2
process-compose -u pc.sock process logs echo --tail 5 > echo.log
if ! grep 2 echo.log; then
  echo "waiting longer"
  sleep 10
  process-compose -u pc.sock process logs echo --tail 5
  process-compose down -u pc.sock
  exit 1
fi
process-compose down -u pc.sock
@F1bonacc1 F1bonacc1 added bug Something isn't working done Done, awaiting release labels Sep 7, 2024
@mkenigs
Copy link
Contributor Author

mkenigs commented Sep 16, 2024

Thanks @F1bonacc1 !

@F1bonacc1
Copy link
Owner

@mkenigs your script was very helpful in pinpointing the issue and validating the fix.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done Done, awaiting release
Projects
None yet
Development

No branches or pull requests

2 participants