skylines icon indicating copy to clipboard operation
skylines copied to clipboard

DB shuts down for no reason when using docker-compose

Open farzinghanbari opened this issue 2 years ago • 0 comments

I have tried to use docker-compose to install skylines and the problem is I see the following error when I'm trying to get flights page:

Sorry! It looks like there was error while loading this page. The error was automatically reported back to the developers. Please try again later!

Apparently this is somehow related to db and this is the output I see on terminal:

api_1       | 172.18.0.1 - - [28/Oct/2021 07:34:16] "GET /flights HTTP/1.1" 200 -
db_1        | 2021-10-28 07:34:17.385 UTC [221] ERROR:  relation "flights" does not exist at character 46
db_1        | 2021-10-28 07:34:17.385 UTC [221] STATEMENT:  SELECT max(flights.date_local) AS date 
db_1        | 	FROM flights JOIN igc_files ON igc_files.id = flights.igc_file_id 
db_1        | 	WHERE flights.takeoff_time < '2021-10-28T07:34:17.289766'::timestamp AND (flights.privacy_level = 0 OR NULL)
api_1       | 172.18.0.1 - - [28/Oct/2021 07:34:17] "GET /api/flights/latest?page=1&column=score&order=desc HTTP/1.1" 500 -
api_1       | Traceback (most recent call last):
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sentry_sdk/integrations/flask.py", line 90, in sentry_patched_wsgi_app
api_1       |     environ, start_response
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sentry_sdk/integrations/wsgi.py", line 131, in __call__
api_1       |     reraise(*_capture_exception(hub))
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sentry_sdk/integrations/wsgi.py", line 127, in __call__
api_1       |     _sentry_start_response, start_response, transaction
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sentry_sdk/integrations/flask.py", line 89, in <lambda>
api_1       |     return SentryWsgiMiddleware(lambda *a, **kw: old_app(self, *a, **kw))(
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 2464, in __call__
api_1       |     return self.wsgi_app(environ, start_response)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/werkzeug/middleware/dispatcher.py", line 66, in __call__
api_1       |     return app(environ, start_response)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sentry_sdk/integrations/flask.py", line 90, in sentry_patched_wsgi_app
api_1       |     environ, start_response
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sentry_sdk/integrations/wsgi.py", line 101, in __call__
api_1       |     return self.app(environ, start_response)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sentry_sdk/integrations/flask.py", line 89, in <lambda>
api_1       |     return SentryWsgiMiddleware(lambda *a, **kw: old_app(self, *a, **kw))(
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 2464, in __call__
api_1       |     return self.wsgi_app(environ, start_response)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 2450, in wsgi_app
api_1       |     response = self.handle_exception(e)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 1867, in handle_exception
api_1       |     reraise(exc_type, exc_value, tb)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 2447, in wsgi_app
api_1       |     response = self.full_dispatch_request()
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
api_1       |     rv = self.handle_user_exception(e)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 1821, in handle_user_exception
api_1       |     reraise(exc_type, exc_value, tb)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
api_1       |     rv = self.dispatch_request()
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/flask/app.py", line 1936, in dispatch_request
api_1       |     return self.view_functions[rule.endpoint](**req.view_args)
api_1       |   File "/home/skylines/code/skylines/api/oauth.py", line 98, in decorated
api_1       |     return f(*args, **kwargs)
api_1       |   File "/home/skylines/code/skylines/api/views/flights.py", line 222, in latest
api_1       |     date_ = query.one().date
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3490, in one
api_1       |     ret = self.one_or_none()
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3459, in one_or_none
api_1       |     ret = list(self)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
api_1       |     return self._execute_and_instances(context)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
api_1       |     result = conn.execute(querycontext.statement, self._params)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
api_1       |     return meth(self, multiparams, params)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
api_1       |     return connection._execute_clauseelement(self, multiparams, params)
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
api_1       |     distilled_params,
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
api_1       |     e, statement, parameters, cursor, context
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
api_1       |     sqlalchemy_exception, with_traceback=exc_info[2], from_=e
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
api_1       |     cursor, statement, parameters, context
api_1       |   File "/root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 609, in do_execute
api_1       |     cursor.execute(statement, parameters)
api_1       | ProgrammingError: (psycopg2.errors.UndefinedTable) relation "flights" does not exist
api_1       | LINE 2: FROM flights JOIN igc_files ON igc_files.id = flights.igc_fi...
api_1       |              ^
api_1       | 
api_1       | [SQL: SELECT max(flights.date_local) AS date 
api_1       | FROM flights JOIN igc_files ON igc_files.id = flights.igc_file_id 
api_1       | WHERE flights.takeoff_time < %(takeoff_time_1)s AND (flights.privacy_level = %(privacy_level_1)s OR NULL)]
api_1       | [parameters: {'privacy_level_1': 0, 'takeoff_time_1': datetime.datetime(2021, 10, 28, 7, 34, 17, 289766)}]
api_1       | (Background on this error at: http://sqlalche.me/e/13/f405)

So I removed all the containers and volume and network and run docker-compose up command again, and this is the result I got:

db_1        | The files belonging to this database system will be owned by user "postgres".
db_1        | This user must also own the server process.
db_1        | 
redis_1     | 1:C 28 Oct 2021 07:32:47.491 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1     | 1:C 28 Oct 2021 07:32:47.491 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1     | 1:C 28 Oct 2021 07:32:47.491 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
db_1        | The database cluster will be initialized with locale "en_US.utf8".
db_1        | The default database encoding has accordingly been set to "UTF8".
db_1        | The default text search configuration will be set to "english".
db_1        | 
db_1        | Data page checksums are disabled.
worker_1    | [2021-10-28 07:32:59,009] INFO in app: Running on git revision ce68ee28
redis_1     | 1:M 28 Oct 2021 07:32:47.492 * monotonic clock: POSIX clock_gettime
redis_1     | 1:M 28 Oct 2021 07:32:47.493 * Running mode=standalone, port=6379.
worker_1    | [2021-10-28 07:32:59,057] INFO in app: Running on git revision ce68ee28
db_1        | 
db_1        | fixing permissions on existing directory /var/lib/postgresql/data ... ok
redis_1     | 1:M 28 Oct 2021 07:32:47.493 # Server initialized
redis_1     | 1:M 28 Oct 2021 07:32:47.493 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1     | 1:M 28 Oct 2021 07:32:47.493 * Ready to accept connections
db_1        | creating subdirectories ... ok
worker_1    | /root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/celery/platforms.py:812: RuntimeWarning: You are running the worker with superuser privileges, which is
worker_1    | absolutely not recommended!
worker_1    | 
worker_1    | Please specify a different user using the -u option.
worker_1    | 
worker_1    | User information: uid=0 euid=0 gid=0 egid=0
worker_1    | 
worker_1    |   uid=uid, euid=euid, gid=gid, egid=egid,
worker_1    | [2021-10-28 07:32:59,119: WARNING/MainProcess] /root/.local/share/virtualenvs/code-t3DK9Vtb/lib/python2.7/site-packages/celery/apps/worker.py:161: CDeprecationWarning: 
worker_1    | Starting from version 3.2 Celery will refuse to accept pickle by default.
worker_1    | 
worker_1    | The pickle serializer is a security concern as it may give attackers
worker_1    | the ability to execute any command.  It's important to secure
worker_1    | your broker from unauthorized access when using pickle, so we think
worker_1    | that enabling pickle should require a deliberate action and not be
worker_1    | the default choice.
worker_1    | 
worker_1    | If you depend on pickle then you should set a setting to disable this
worker_1    | warning and to be sure that everything will continue working
worker_1    | when you upgrade to Celery 3.2::
worker_1    | 
worker_1    |     CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
worker_1    | 
worker_1    | You must only enable the serializers that you will actually use.
worker_1    | 
worker_1    | 
worker_1    |   warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
worker_1    | [2021-10-28 07:32:59,583: INFO/MainProcess] Connected to redis://redis:6379/0
db_1        | selecting default max_connections ... 100
worker_1    | [2021-10-28 07:32:59,597: INFO/MainProcess] mingle: searching for neighbors
db_1        | selecting default shared_buffers ... 128MB
db_1        | selecting default timezone ... Etc/UTC
db_1        | selecting dynamic shared memory implementation ... posix
db_1        | creating configuration files ... ok
db_1        | running bootstrap script ... ok
db_1        | performing post-bootstrap initialization ... ok
db_1        | syncing data to disk ... ok
db_1        | 
db_1        | Success. You can now start the database server using:
db_1        | 
db_1        |     pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1        | 
db_1        | 
db_1        | WARNING: enabling "trust" authentication for local connections
db_1        | You can change this by editing pg_hba.conf or using the option -A, or
db_1        | --auth-local and --auth-host, the next time you run initdb.
db_1        | waiting for server to start....2021-10-28 07:32:59.971 UTC [62] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1        | 2021-10-28 07:33:00.441 UTC [63] LOG:  database system was shut down at 2021-10-28 07:32:53 UTC
db_1        | 2021-10-28 07:33:00.501 UTC [62] LOG:  database system is ready to accept connections
db_1        |  done
db_1        | server started
worker_1    | [2021-10-28 07:33:00,604: INFO/MainProcess] mingle: all alone
worker_1    | [2021-10-28 07:33:00,617: WARNING/MainProcess] celery@cf4961e6b0f7 ready.
db_1        | 
db_1        | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/create-databases.sql
db_1        | CREATE DATABASE
db_1        | You are now connected to database "skylines" as user "postgres".
tracking_1  | [2021-10-28 07:33:01,826] INFO in app: Running on git revision ce68ee28
tracking_1  | Receiving datagrams on :5597
tracking_1  | [2021-10-28 07:33:01,866] INFO in app: Running on git revision ce68ee28
api_1       | [2021-10-28 07:33:01,997] INFO in app: Running on git revision ce68ee28
api_1       | [2021-10-28 07:33:02,028] INFO in app: Running on git revision ce68ee28
api_1       | [2021-10-28 07:33:02,064] INFO in app: Running on git revision ce68ee28
api_1       |  * Serving Flask app "skylines.frontend" (lazy loading)
api_1       |  * Environment: production
api_1       |    WARNING: This is a development server. Do not use it in a production deployment.
api_1       |    Use a production WSGI server instead.
api_1       |  * Debug mode: on
api_1       |  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
api_1       |  * Restarting with stat
db_1        | CREATE EXTENSION
api_1       | [2021-10-28 07:33:03,141] INFO in app: Running on git revision ce68ee28
db_1        | CREATE EXTENSION
api_1       | [2021-10-28 07:33:03,172] INFO in app: Running on git revision ce68ee28
api_1       | [2021-10-28 07:33:03,211] INFO in app: Running on git revision ce68ee28
api_1       |  * Debugger is active!
api_1       |  * Debugger PIN: 273-665-450
db_1        | CREATE DATABASE
db_1        | You are now connected to database "skylines_test" as user "postgres".
db_1        | CREATE EXTENSION
db_1        | CREATE EXTENSION
db_1        | 
db_1        | 
db_1        | 2021-10-28 07:33:06.592 UTC [62] LOG:  received fast shutdown request
db_1        | waiting for server to shut down....2021-10-28 07:33:06.682 UTC [62] LOG:  aborting any active transactions
db_1        | 2021-10-28 07:33:06.684 UTC [62] LOG:  worker process: logical replication launcher (PID 69) exited with exit code 1
db_1        | 2021-10-28 07:33:06.684 UTC [64] LOG:  shutting down
db_1        | .2021-10-28 07:33:07.628 UTC [62] LOG:  database system is shut down
db_1        |  done
db_1        | server stopped
db_1        | 
db_1        | PostgreSQL init process complete; ready for start up.
db_1        | 
db_1        | 2021-10-28 07:33:07.756 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1        | 2021-10-28 07:33:07.756 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db_1        | 2021-10-28 07:33:07.845 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1        | 2021-10-28 07:33:08.002 UTC [101] LOG:  database system was shut down at 2021-10-28 07:33:07 UTC
db_1        | 2021-10-28 07:33:08.094 UTC [1] LOG:  database system is ready to accept connections

What is interesting for me is the part about:

db_1        | 2021-10-28 07:33:06.592 UTC [62] LOG:  received fast shutdown request
db_1        | waiting for server to shut down....2021-10-28 07:33:06.682 UTC [62] LOG:  aborting any active transactions
db_1        | 2021-10-28 07:33:06.684 UTC [62] LOG:  worker process: logical replication launcher (PID 69) exited with exit code 1
db_1        | 2021-10-28 07:33:06.684 UTC [64] LOG:  shutting down
db_1        | .2021-10-28 07:33:07.628 UTC [62] LOG:  database system is shut down
db_1        |  done
db_1        | server stopped

Unfortunately, I have no idea how containers of this project are organized and I have no idea how to debug this problem. So I'd really appreciate any help.

farzinghanbari avatar Oct 28 '21 07:10 farzinghanbari