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

[Feature Request]: Add more specific error message on database timeout #411

Closed
dadeppa opened this issue Dec 21, 2023 · 3 comments
Closed
Labels
enhancement It's not a bug, but it's worth an enhancement.

Comments

@dadeppa
Copy link

dadeppa commented Dec 21, 2023

Description / Beschreibung

In short: Please add a specific debug message if database connection fails due timeout.

In long:
After installing a new adapter I needed to connect an USB device, so I changed the docker config and restarted the container. Afterwards the system did not work any longer, error message was:
Checking Database connection... Failed. Please check your configuration and try again.

Set ENV DEBUG to true to get more details, but forgot to safe the outputs.
Switched some versions of the image (started from my stable running 8.1.0, went to latest / 9.0.1 and back).

Then set up ENV variables for IOB_STATESDB_TYPE / IOB_OBJECTSDB_TYPE / ff to json and corresponding values. Ran into failed DB check again.
Found this post in ioBroker forums, changed connectTimeout in objects and states in iobroker/iobroker-data/iobroker.json and then ioBroker ran again.
Took me quite a while to figure this out. I am not sure if there is a hint somewhere in the docs - did not find it yet. So I am requesting an additional debug / error message after checking db type / connection and running in an error due timeout.

Thank you for the really good work ( :) ).

@dadeppa dadeppa added the enhancement It's not a bug, but it's worth an enhancement. label Dec 21, 2023
@buanet
Copy link
Owner

buanet commented Jan 7, 2024

Not sure how to do that as ioBroker gives no specific output with the actual command i use for database check.

https://github.com/buanet/ioBroker.docker/blob/0cbfd67f5a97cfee8615c9434e34b54721340c72/debian12/scripts/iobroker_startup.sh#L334C28-L334C28

Any ideas?

Regards,
André

@dadeppa
Copy link
Author

dadeppa commented Jan 14, 2024

Hi Andre,

sorry for keep you waiting. Tbh I am really low level linux user, so I hunted the script through ChatGPT, he suggested this at a first glace:

set +e
if gosu iobroker iob uuid &> /dev/null; then
  echo "Done."
  echo " "
else
  errormsg=$(gosu iobroker iob uuid 2>&1 | sed 's/^/[DEBUG] /')
  exit_status=$?
  set -e
  
  if [[ $exit_status -eq 124 ]]; then
    # Handle timeout error
    echo "Failed due to a timeout. The database might be too large."
    if [[ "$debug" == "true" ]]; then
      echo "[DEBUG] Error message: "
      echo "$errormsg"
    fi
    echo "Consider increasing the timeout or optimizing your database."
    echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs)."
    stop_on_error
  else
    # Handle other errors
    echo "Failed."
    if [[ "$debug" == "true" ]]; then
      echo "[DEBUG] Error message: "
      echo "$errormsg"
    fi
    echo "Please check your configuration and try again."
    echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs)."
    stop_on_error
  fi
fi

with the hints:

  • The exit_status variable is introduced to capture the exit status of the gosu iobroker iob uuid command.
  • If the exit status is 124, which typically indicates a timeout error, it will print a specific message and stop the script.
  • If the exit status is different, it will handle other errors as before.

I am not sure whether it is possible to access the exit status in the way chat GPT suggests.

Another Thing is, if we know the timeout, we may just run a stopwatch and assume that it depended on a timeout if the database connection is exiting after the timeout value from /opt/iobroker/iobroker-data

@buanet
Copy link
Owner

buanet commented Apr 5, 2024

I took a look into the startup script. It turned out, that there is still a logging output when database check fails. But until now, this was only shown when debug log was active.
Looked that way:

Checking database connection... Failed.
[DEBUG] Error message: 
[DEBUG] No connection to states foo:6379[redis]
Please check your configuration and try again.
For more information see ioBroker Docker image docs (https://docs.buanet.de/iobroker-docker-image/docs).

I changed this to be displayed every time the check fails. I do not plan to put more energy into this.
Enhancement will be available with upcoming v9.2.0-beta.1.

Regards,
André

@buanet buanet closed this as completed Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement It's not a bug, but it's worth an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants