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

OperationalError: FATAL: #169

Closed
riddertommie opened this issue Feb 8, 2021 · 6 comments
Closed

OperationalError: FATAL: #169

riddertommie opened this issue Feb 8, 2021 · 6 comments

Comments

@riddertommie
Copy link

riddertommie commented Feb 8, 2021

Setup/Architecture information

I'm user the docker version and configured it as receiver. I'm using a raspberry together with DSMR datalogger (hassio addon) https://github.com/sanderdw/hassio-addons.
-->

Version of the Docker image

xirixiz/dsmr-reader-docker:latest

Configuration

version: '2'

services:
dsmrdb:
image: postgres:12-alpine
container_name: DSMR_db
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- /opt/DSMR/dsmrdb:/var/lib/postgresql/data
environment:
- TZ=Europe/Amsterdam
- PG_TZ=Europe/Amsterdam
- POSTGRES_USER=dsmrreader
- POSTGRES_PASSWORD=dsmrreader
- POSTGRES_DB=dsmrreader

dsmr:
image: xirixiz/dsmr-reader-docker:latest
container_name: DSMR
depends_on:
- dsmrdb
cap_add:
- NET_ADMIN
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- /opt/DSMR/dsmr_backups:/dsmr/backups
environment:
- DJANGO_TIME_ZONE=Europe/Amsterdam
- VIRTUAL_HOST=localhost
- ENABLE_NGINX_SSL=false
- DATALOGGER_MODE=receiver
ports:
- 7777:80

#volumes:
#dsmrdb:
#dsmrdb_backups:

Add your docker(-compose) config file here.


## Describe the bug

Its stops and trows out a error (almost every day). The only resetting the container helps 

## Debug log

OperationalError: FATAL:  could not open file "global/pg_filenode.map": Permission denied

Traceback:
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)

  File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)

  File "/dsmr/dsmr_frontend/mixins.py", line 10, in dispatch
    if not FrontendSettings.get_solo().always_require_login:

  File "/usr/local/lib/python3.9/site-packages/solo/models.py", line 55, in get_solo
    obj, created = cls.objects.get_or_create(pk=cls.singleton_instance_id)

  File "/usr/local/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 573, in get_or_create
    return self.get(**kwargs), False

  File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 425, in get
    num = len(clone)

  File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 269, in __len__
    self._fetch_all()

  File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 1308, in _fetch_all
    self._result_cache = list(self._iterable_class(self))

  File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)

  File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1154, in execute_sql
    cursor = self.connection.cursor()

  File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 259, in cursor
    return self._cursor()

  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 235, in _cursor
    self.ensure_connection()

  File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
    self.connect()

  File "/usr/local/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value

  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
    self.connect()

  File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 200, in connect
    self.connection = self.get_new_connection(conn_params)

  File "/usr/local/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
    connection = Database.connect(**conn_params)

  File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

@xirixiz
Copy link
Owner

xirixiz commented Feb 8, 2021

It seems to be related to a permission error looking at the logs. Could you please verify permissions of the file global/pg_filenode.map and compare it with other files in the same directory.

For me the owner and group are both 70 on the host system with most (maybe all) of the files 600 rights.

sudo chown -R 70:70 /opt/DSMR/dsmrdb
sudo chmod -R 600 /opt/DSMR/dsmrdb

Sample:
-rw------- 1 70 70 512 Feb 3 12:58 pg_filenode.map

@riddertommie
Copy link
Author

riddertommie commented Feb 8, 2021

Checked an the group was not 70 I changed it so lets wait if it comes back (wil let you know). I'm almost sure that this will happen again if i upgrade to a newer version. Is there something i did wrong?

Thanks!

Update, as soon as i do the chown and the chmod everything stops working, dmsr can't connect to the database anymore so nothing is starting.

@xirixiz
Copy link
Owner

xirixiz commented Feb 9, 2021

Maybe try the postgres:12 docker images instead of the Alpine one. The last few days I received more messages from people having issues with the Alpine release. Can you give it a shot?

@xirixiz
Copy link
Owner

xirixiz commented Feb 10, 2021

#171

@xirixiz
Copy link
Owner

xirixiz commented Feb 12, 2021

Any update?

@xirixiz xirixiz closed this as completed Feb 12, 2021
@riddertommie
Copy link
Author

Seems to be holding, no errors yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants