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

502 Bad Gateway #5

Closed
fuzunspm opened this issue Jan 1, 2019 · 28 comments
Closed

502 Bad Gateway #5

fuzunspm opened this issue Jan 1, 2019 · 28 comments

Comments

@fuzunspm
Copy link

fuzunspm commented Jan 1, 2019

Problem/Motivation

I’m getting bad gateway when tryin to access web ui, no error log and I tried different ports but no luck

@addons-assistant
Copy link

👋 Thanks for opening your first issue here! If you're reporting a 🐛 bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be usefull.

@frenck
Copy link
Member

frenck commented Jan 1, 2019

  • Have you checked the logs?
  • Please provide logs. There is nothing for me to do with this one sentence.

@fuzunspm
Copy link
Author

fuzunspm commented Jan 1, 2019

All it says is:

2019-01-01 22:04:50 INFO: HikariPool-1 - Starting...
2019-01-01 22:04:52 INFO: HikariPool-1 - Start completed.
2019-01-01 22:05:08 INFO: Clearing database change log checksums
2019-01-01 22:05:09 INFO: SELECT COUNT() FROM PUBLIC.DATABASECHANGELOGLOCK
2019-01-01 22:05:09 INFO: SELECT COUNT(
) FROM PUBLIC.DATABASECHANGELOGLOCK
2019-01-01 22:05:09 INFO: SELECT LOCKED FROM PUBLIC.DATABASECHANGELOGLOCK WHERE ID=1
2019-01-01 22:05:10 INFO: Waiting for changelog lock....

@hubgitbb
Copy link

hubgitbb commented Jan 7, 2019

same proble here with the same logs
i am runing Home Assistant 0.84.6

@Aterfax
Copy link

Aterfax commented Jan 8, 2019

Also can confirm this error.

ERROR: Main method error - Could not acquire change log lock. Currently locked by homeassistant (172.30.32.1) since 1/8/19 3:01 AM - LockException (... < DataManager:310 < *:90 < Context:382 < Main:110 < ...) Exception in thread "main" java.lang.RuntimeException: liquibase.exception.LockException: Could not acquire change log lock. Currently locked by homeassistant (172.30.32.1) since 1/8/19 3:01 AM

I am fairly sure now that this error is related to the addon getting restarted before the install has completed leading to the database being stuck in a locked state.

To resolve this error, simply uninstall and re-install giving it plenty of time even when it is giving a 502 error to finish completing the install.

This may be a significant amount of time on slow devices.

@hubgitbb
Copy link

hubgitbb commented Jan 8, 2019

re-installing worked for me. thx

@cybergrimes
Copy link

cybergrimes commented Jan 17, 2019

Same issue so I reinstalled/restarted HA. I thought I was still getting the error but it looks like it just took a while for it to start the service. It's running now.

@frenck
Copy link
Member

frenck commented Feb 3, 2019

There is no control from my end possible in this department.

@bandric1
Copy link

That issue i experienced while i was on RPI3B+ MariaDB would lock a table and would not unlock it even if request was issued. After i moved to Laptop i havent experienced that issue any more.
This is somehow R/W bug in MariaDB it locks. I found the sollution of using remote MariaDB to which i could connect with remote tool (sequel pro) if that happened i could easily unlock the database table and continue.

@Aterfax
Copy link

Aterfax commented Apr 18, 2019

I have had this happen too often and the quickest way to resolve it is just deleting the DB. This does lose the data so it might be a better solution that the docker start script has a section written in to force an unlock of the tables prior to Traccar start up.

This shouldn't cause issues as the file locking can't possibly actually be occurring since the docker just restarted but I do not know the commands to achieve this.

@myopenflixr
Copy link

I am experiencing this issue as well. I originally uninstalled and deleted the database....reinstalled....and it worked fine.

However, when I just performed a reboot of my RPi3-B+, I now have the same issue.

This needs to be resolved. I would rather not have to uninstall....delete database....and then reinstall every time I need to reboot my RPi.

@Aterfax
Copy link

Aterfax commented Apr 26, 2019

Agreed - @frenck any chance you could add a force unlock to the database as part of the docker start scripting?

@bigbigblue
Copy link

+1 for this problem. How do I delete the database as mentioned by Aterfax?
Thanks

@Aterfax
Copy link

Aterfax commented May 8, 2019 via email

@BatterBits
Copy link

BatterBits commented May 20, 2019

I'm having the same problem. I'm more than happy to get my "hands dirty" - if I only knew where/how to start.
I'm using Hassio - and can't find how to "get into" the docker - and there's nothing which looks right under /usr/share - there's no usr/share/hassio on my device.

@Aterfax
Copy link

Aterfax commented May 21, 2019

Then the folder structure depends on how you've installed Hassio I suspect.

Using the "where" command on the hassio executables might help?

@BatterBits
Copy link

BatterBits commented May 21, 2019

Okay - so to update my previous - it seems I was using a protected mode (from within Hassio - IDE) so wasn't able to see the docker processes.

Here's how to do it.
Access your Hassio via SSH - I wasn't able to get Hassio tools IDE to work, but managed inHassio add-on SSH&Web Terminal, but I had to turn "protected mode" off - toggle switch in top panel.

Run command
docker ps |grep traccar
this will produce a listing where the first column has a number in Hex - this is the ID of the container.
Then run

docker exec <your ID from previous step> ls -ltr /data

This should list 2 databases which can be removed as follows:
docker exec <your ID > rm /data/traccar.trace.db
docker exec <your ID > rm /data/traccar.mv.db

Now you can restart your Hassio traccar addon, and traccar will re-create the databases.

@Aterfax
Copy link

Aterfax commented Jun 6, 2019

I have had the DB corrupt (left itself locked somehow) itself again out of nowhere - something is needed to resolve this issue and remove the DB lock on start up or this plugin is basically un-usable.

@bigbigblue
Copy link

I have had the DB corrupt (left itself locked somehow) itself again out of nowhere - something is needed to resolve this issue and remove the DB lock on start up or this plugin is basically un-usable.

I have had the same happen AGAIN. It is so annoying to have to re-enter the Traccar data evry time this happens. I agree with Aterfax that unless the problem can be fixed, the plugin is un-usable. I really appreciate the work put in to provide this plugin to HomeAssistant but I use Traccar as a security device and the one thing a security device needs to be is reliable.

@bigbigblue
Copy link

I have found a little more information on this error. Apparently the database used in the Traccar Plugin is Liquibase. the Locks can be released by issuing the command 'Liquibase releaseLocks' command will clear the locks - problem is that Liquibase is not a known command in the docker container.
The following SQL would work :
UPDATE DATABASECHANGELOGLOCK SET LOCKED=FALSE, LOCKGRANTED=null, LOCKEDBY=null where ID=1;

As would dropping the DATABASECHANGELOGLOCK table (which would be automatically recreated.
Therefore it looks like a simple change to the plugin would resolve this problem. Given that only one client will ever be updating the database, locking isn't even required!

@Aterfax
Copy link

Aterfax commented Jun 14, 2019

Pretty sure this will need the H2 console to achieve!

http://www.h2database.com/html/tutorial.html

That is, either by fixing the file by downloading it and running the commands above after connecting to the DB or by running H2 console commands during docker startup.

See: https://www.traccar.org/forums/topic/how-to-remove-lock-databasechangeloglock-default-h2-database/#post-42414

Edit: I should add - ideally this implementation should stop using H2 anyway*

@bigbigblue
Copy link

bigbigblue commented Jun 15, 2019

Pretty sure this will need the H2 console to achieve!

Not a fix, but a (relatively) easy way to overcome the problem - install the MariaDB addon in HassOS and follow the instructions here https://www.traccar.org/mysql/ to tell Traccar to use MariaDB. You can then use a MySQL admin tool (such as the Chrome MYSQL admin tool) to manage the database, including dropping the lock table if Traccar gets in a mess.
This obviously doesn't prevent the problem, but helps you to recover from it quite easily.
I also wonder if, with MariaDB installed, the APPDaemon plugin could be used to drop the lock table each time Homeassistant starts, to prevent the problem from occurring?

@bigbigblue
Copy link

I have a working bypass for this - using MariaDB and Appdaemon plugins to HomeAssistant I am happy to share it if anyone needs it.

@frenck
Copy link
Member

frenck commented Jun 23, 2019

I agree, I should provide a way to hookup the add-on to MySQL.

@frenck
Copy link
Member

frenck commented Jun 23, 2019

Another option would be sqlite of course, which might be more portable in case of an add-on.

@frenck
Copy link
Member

frenck commented Jun 24, 2019

Actually, I'm not going to do this, instead, let's adjust the manual on how to configure Traccar for MySQL (Since you can do that, because the configuration XML is available for the user).

That way, the add-on still works out of the box, but a user can decide himself to which database he wants it to connect (e.g., sqlite, postgress or mysql).

@frenck
Copy link
Member

frenck commented Jun 24, 2019

How to use MariaDB/MySQL with this add-on has now been documented in the add-on documentation.
Also, a recommendation to use it has been added to the installation steps.

@frenck frenck closed this as completed Jun 24, 2019
@addons-assistant
Copy link

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@addons-assistant addons-assistant bot locked as resolved and limited conversation to collaborators Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants