matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.8k stars 2.13k forks source link

failed :attempt to write readonly database #7080

Closed learnwithsobhit closed 4 years ago

learnwithsobhit commented 4 years ago

i have configured docker build for synapse then establishing user login using keycloak server ,but while registering client inside docker image i am getting following error (if i run synapse without docker it works fine) sqlite3.OperationalError: attempt to write a readonly database

i am mounting the /data of container with my updated data folder in the host with required files and configuration of keycloak and homeserver.yaml

more error info as below -->

2020-03-15 14:12:56,732 - synapse.handlers.saml_handler - 142 - INFO - POST-7 - SAML2 assertion: (1)...ment></ns0:Assertion> 2020-03-15 14:12:56,732 - synapse.handlers.saml_handler - 146 - INFO - POST-7 - SAML2 mapped attributes: {'uid': ['admin123']} 2020-03-15 14:12:56,733 - synapse.handlers.saml_handler - 162 - INFO - POST-7 - Looking for existing mapping for user saml:admin123 2020-03-15 14:12:56,736 - synapse.handlers.saml_handler - 184 - INFO - POST-7 - Looking for existing account based on mapped uid @admin123:my.domain.name 2020-03-15 14:12:56,738 - synapse.handlers.saml_handler - 232 - INFO - POST-7 - Mapped SAML user to local part admin123 2020-03-15 14:12:56,742 - synapse.storage.database - 389 - WARNING - POST-7 - [TXN OPERROR] {register_user-31} attempt to write a readonly database 0/5 2020-03-15 14:12:56,744 - synapse.storage.database - 389 - WARNING - POST-7 - [TXN OPERROR] {register_user-31} attempt to write a readonly database 1/5 2020-03-15 14:12:56,746 - synapse.storage.database - 389 - WARNING - POST-7 - [TXN OPERROR] {register_user-31} attempt to write a readonly database 2/5 2020-03-15 14:12:56,747 - synapse.storage.database - 389 - WARNING - POST-7 - [TXN OPERROR] {register_user-31} attempt to write a readonly database 3/5 2020-03-15 14:12:56,749 - synapse.storage.database - 389 - WARNING - POST-7 - [TXN OPERROR] {register_user-31} attempt to write a readonly database 4/5 2020-03-15 14:12:56,750 - synapse.storage.database - 389 - WARNING - POST-7 - [TXN OPERROR] {register_user-31} attempt to write a readonly database 5/5 2020-03-15 14:12:56,751 - synapse.http.server - 183 - ERROR - POST-7 - Failed handle request <XForwardedForRequest at 0x7f3a0e45cd50 method='POST' uri='/_matrix/saml2/authn_response' clientproto='HTTP/1.1' site=8008> Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/synapse/http/server.py", line 144, in wrapped_request_handler return await h(self, request) File "/usr/local/lib/python3.7/site-packages/synapse/rest/saml2/response_resource.py", line 31, in _async_render_POST return await self._saml_handler.handle_saml_response(request) File "/usr/local/lib/python3.7/site-packages/synapse/handlers/saml_handler.py", line 117, in handle_saml_response user_id = await self._map_saml_response_to_user(resp_bytes, relay_state) File "/usr/local/lib/python3.7/site-packages/synapse/handlers/saml_handler.py", line 235, in _map_saml_response_to_user localpart=localpart, default_display_name=displayname File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks result = result.throwExceptionIntoGenerator(g) File "/usr/local/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) File "/usr/local/lib/python3.7/site-packages/synapse/handlers/register.py", line 203, in register_user address=address, File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks result = result.throwExceptionIntoGenerator(g) File "/usr/local/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 495, in runInteraction kwargs File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks result = result.throwExceptionIntoGenerator(g) File "/usr/local/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator return g.throw(self.type, self.value, self.tb) File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 543, in runWithConnection self._db_pool.runWithConnection(inner_func, *args, *kwargs) File "/usr/local/lib/python3.7/site-packages/twisted/python/threadpool.py", line 250, in inContext result = inContext.theWork() File "/usr/local/lib/python3.7/site-packages/twisted/python/threadpool.py", line 266, in inContext.theWork = lambda: context.call(ctx, func, args, kw) File "/usr/local/lib/python3.7/site-packages/twisted/python/context.py", line 122, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, kw) File "/usr/local/lib/python3.7/site-packages/twisted/python/context.py", line 85, in callWithContext return func(*args,*kw) File "/usr/local/lib/python3.7/site-packages/twisted/enterprise/adbapi.py", line 306, in _runWithConnection compat.reraise(excValue, excTraceback) File "/usr/local/lib/python3.7/site-packages/twisted/python/compat.py", line 464, in reraise raise exception.with_traceback(traceback) File "/usr/local/lib/python3.7/site-packages/twisted/enterprise/adbapi.py", line 297, in _runWithConnection result = func(conn, args, kw) File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 540, in inner_func return func(conn, *args, *kwargs) File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 378, in new_transaction r = func(cursor, args, *kwargs) File "/usr/local/lib/python3.7/site-packages/synapse/storage/data_stores/main/registration.py", line 1078, in _register_user "user_type": user_type, File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 621, in simple_insert_txn txn.execute(sql, vals) File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 175, in execute self._do_execute(self.txn.execute, sql, args) File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 201, in _do_execute return func(sql, *args) sqlite3.OperationalError: attempt to write a readonly database

richvdh commented 4 years ago

sounds like a permissions problem with the docker volume mount.

Github isn't a good place to get support for this: you could try #synapse:matrix.org but honestly this sounds like standard docker stuff rather than anything specific to synapse.

benpbolton commented 3 years ago

Depending on the context it might also be the sandboxing of the systemd script for matrix-synapse.service... in it, a directive of ProtectSystem=strict, when matrix-synapse is utilizing an alternate or unconventional file location, might also require a ReadWritePaths= directive to allow the service to access the database, media, etc in that other mount point...