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

Docker image sqlite3 error readonly database #259

Open
itz-Jana opened this issue Nov 5, 2020 · 3 comments
Open

Docker image sqlite3 error readonly database #259

itz-Jana opened this issue Nov 5, 2020 · 3 comments

Comments

@itz-Jana
Copy link

itz-Jana commented Nov 5, 2020

I'm currently in the process of migrating my entire application catalog over to Docker.

I've used the docker-compose settings from the README, with the addition an addition for FORWARD_ALLOW_IPS = *

version: '3.7'
services:
  syncserver:
    container_name: syncserver
    image: mozilla/syncserver:latest
    volumes:
      - ./data:/data
    ports:
      - 5000:5000
    environment:
      SYNCSERVER_PUBLIC_URL: 'https://***REMOVED***/'
      SYNCSERVER_SECRET: '***REMOVED***'
      SYNCSERVER_SQLURI: 'sqlite:////data/syncserver.db'
      SYNCSERVER_BATCH_UPLOAD_ENABLED: 'true'
      SYNCSERVER_FORCE_WSGI_ENVIRON: 'false'
      SYNCSERVER_FORWARDED_ALLOW_IPS: '*'
      PORT: '5000'
    restart: always

I then created the ./data directory and copied my old syncserver.db there.
I then had an issue with it not being able to open the database. I fixed that by chowning the database to the 1001:1001 user, that is used inside of the container.

root@*****:/opt/syncserver-docker/data# ls -alhFn
total 61M
drwxr-xr-x 2    0    0 4.0K Nov  5 14:51 ./
drwxr-xr-x 3    0    0 4.0K Nov  5 15:12 ../
-rw------- 1 1001 1001  61M Nov  5 15:14 syncserver.db

Now I am consistently receiving this error:

Starting syncserver ... done
Attaching to syncserver
syncserver    | [2020-11-05 14:14:46 +0000] [6] [INFO] Starting gunicorn 19.6.0
syncserver    | [2020-11-05 14:14:46 +0000] [6] [INFO] Listening at: http://0.0.0.0:5000 (6)
syncserver    | [2020-11-05 14:14:46 +0000] [6] [INFO] Using worker: sync
syncserver    | [2020-11-05 14:14:46 +0000] [14] [INFO] Booting worker with pid: 14
syncserver    | /usr/local/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.2) or chardet (3.0.4) doesn't match a supported version!
syncserver    |   RequestsDependencyWarning)
syncserver    | ERROR:syncstorage.storage.sql.dbconnect:Caught operational db error: (sqlite3.OperationalError) attempt to write a readonly database
syncserver    | [SQL: INSERT INTO batch_uploads (batch, userid, collection) VALUES (?, ?, ?) /* [queryName=CREATE_BATCH] */]
syncserver    | [parameters: (1604585691571, 1, 4)]
syncserver    | (Background on this error at: http://sqlalche.me/e/e3q8)
syncserver    | Traceback (most recent call last):
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/dbconnect.py", line 559, in report_backend_errors_wrapper
syncserver    |     return func(self, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/dbconnect.py", line 655, in execute
syncserver    |     return self._exec_with_cleanup(connection, query_str, **params)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/mozsvc/metrics.py", line 183, in timed_func
syncserver    |     return func(*args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/dbconnect.py", line 689, in _exec_with_cleanup
syncserver    |     return connection.execute(sqltext(query_str), **params)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute
syncserver    |     return meth(self, multiparams, params)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
syncserver    |     return connection._execute_clauseelement(self, multiparams, params)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
syncserver    |     distilled_params,
syncserver    |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
syncserver    |     e, statement, parameters, cursor, context
syncserver    |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
syncserver    |     util.raise_from_cause(sqlalchemy_exception, exc_info)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause
syncserver    |     reraise(type(exception), exception, tb=exc_tb, cause=cause)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
syncserver    |     cursor, statement, parameters, context
syncserver    |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute
syncserver    |     cursor.execute(statement, parameters)
syncserver    | OperationalError: (sqlite3.OperationalError) attempt to write a readonly database
syncserver    | [SQL: INSERT INTO batch_uploads (batch, userid, collection) VALUES (?, ?, ?) /* [queryName=CREATE_BATCH] */]
syncserver    | [parameters: (1604585691571, 1, 4)]
syncserver    | (Background on this error at: http://sqlalche.me/e/e3q8)
syncserver    | 
syncserver    | ERROR:syncstorage.views:Could not create batch
syncserver    | ERROR:syncstorage.views:BackendError
syncserver    | 
syncserver    | (sqlite3.OperationalError) attempt to write a readonly database
syncserver    | [SQL: INSERT INTO batch_uploads (batch, userid, collection) VALUES (?, ?, ?) /* [queryName=CREATE_BATCH] */]
syncserver    | [parameters: (1604585691571, 1, 4)]
syncserver    | (Background on this error at: http://sqlalche.me/e/e3q8)
syncserver    | ERROR:mozsvc:5976228c4c1e61400132a745fdc53905
syncserver    | ERROR:mozsvc:BackendError
syncserver    | 
syncserver    | (sqlite3.OperationalError) attempt to write a readonly database
syncserver    | [SQL: INSERT INTO batch_uploads (batch, userid, collection) VALUES (?, ?, ?) /* [queryName=CREATE_BATCH] */]
syncserver    | [parameters: (1604585691571, 1, 4)]
syncserver    | (Background on this error at: http://sqlalche.me/e/e3q8)
syncserver    | Traceback (most recent call last):
syncserver    |   File "/usr/local/lib/python2.7/site-packages/mozsvc/tweens.py", line 26, in catch_backend_errors_tween
syncserver    |     return handler(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/pyramid/tweens.py", line 21, in excview_tween
syncserver    |     response = handler(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/pyramid/router.py", line 163, in handle_request
syncserver    |     response = view_callable(context, request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/pyramid/config/views.py", line 596, in __call__
syncserver    |     return view(context, request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/pyramid/config/views.py", line 329, in attr_view
syncserver    |     return view(context, request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/pyramid/config/views.py", line 305, in predicate_wrapper
syncserver    |     return view(context, request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/pyramid/config/views.py", line 245, in _secured_view
syncserver    |     return view(context, request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/pyramid/config/views.py", line 355, in rendered_view
syncserver    |     result = view(context, request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/pyramid/config/views.py", line 501, in _requestonly_view
syncserver    |     response = view(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/cornice/service.py", line 514, in wrapper
syncserver    |     response = view_(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/util.py", line 54, in wrapper
syncserver    |     return decorator_func(target_func, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/decorators.py", line 222, in check_migration
syncserver    |     return viewfunc(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/util.py", line 54, in wrapper
syncserver    |     return decorator_func(target_func, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/decorators.py", line 48, in convert_storage_errors
syncserver    |     return viewfunc(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/util.py", line 54, in wrapper
syncserver    |     return decorator_func(target_func, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/decorators.py", line 79, in sleep_and_retry_on_conflict
syncserver    |     return viewfunc(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/util.py", line 54, in wrapper
syncserver    |     return decorator_func(target_func, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/decorators.py", line 202, in with_collection_lock
syncserver    |     return viewfunc(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/util.py", line 54, in wrapper
syncserver    |     return decorator_func(target_func, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/decorators.py", line 172, in check_precondition_headers
syncserver    |     return viewfunc(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/util.py", line 54, in wrapper
syncserver    |     return decorator_func(target_func, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/decorators.py", line 110, in check_storage_quota
syncserver    |     return viewfunc(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/__init__.py", line 380, in post_collection
syncserver    |     return post_collection_batch(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/util.py", line 54, in wrapper
syncserver    |     return decorator_func(target_func, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/decorators.py", line 222, in check_migration
syncserver    |     return viewfunc(request)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/views/__init__.py", line 424, in post_collection_batch
syncserver    |     batch = storage.create_batch(user, collection)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/__init__.py", line 108, in with_session_wrapper
syncserver    |     return func(self, session, *args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/__init__.py", line 551, in create_batch
syncserver    |     session.query("CREATE_BATCH", params)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/__init__.py", line 80, in convert_db_errors_wrapper
syncserver    |     return func(*args, **kwds)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/__init__.py", line 1098, in query
syncserver    |     return self.connection.query(query, params)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/dbconnect.py", line 774, in query
syncserver    |     res = self.execute(query, params, annotations)
syncserver    |   File "/usr/local/lib/python2.7/site-packages/syncstorage/storage/sql/dbconnect.py", line 571, in report_backend_errors_wrapper
syncserver    |     raise BackendError(str(exc))
syncserver    | BackendError: BackendError
syncserver    | 
syncserver    | (sqlite3.OperationalError) attempt to write a readonly database
syncserver    | [SQL: INSERT INTO batch_uploads (batch, userid, collection) VALUES (?, ?, ?) /* [queryName=CREATE_BATCH] */]
syncserver    | [parameters: (1604585691571, 1, 4)]
syncserver    | (Background on this error at: http://sqlalche.me/e/e3q8)
syncserver    | 
syncserver    | user: {'node': u'https://***REMOVED***', 'uid': 1, 'fxa_kid': u'1562698448572-Bg_mB78FL7l2qGaDQZHz6Q', 'fxa_uid': u'5f219e00709245f8a6de33e600b43af3', 'hashed_device_id': u'aebb74c3290ebb30c9b01fd2b3c3f012', 'hashed_fxa_uid': u'9093c73c78b7120c11e5ed05318795da'}

Does anyone have any idea, what could be the reason for this behaviour?
I properly shutdown the old syncserver, before copying over the database file.

@afshawnlotfi
Copy link

Same issue here

@afshawnlotfi
Copy link

Ah, as it says in the readme kinda indirectly you have to do: sudo chown -R 1001:1001 syncserver/

@thematrixdev
Copy link

I have been looking for where to download the syncserver.db and how to create an empty syncserver.db... I should have came here earlier...

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

3 participants