haiwen / seafile

High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features.
http://seafile.com/
Other
12.35k stars 1.55k forks source link

Seafile Drive Client removes account when server temporarily unavailable #2822

Open phiradd opened 1 month ago

phiradd commented 1 month ago

I have got a seafile server running in a docker container on a QNAP NAS with the default configuration files (I have not changed any settings yet). It works very well but I have an issue whenever the NAS is not reachable, the account is removed from Seafile Drive Client 3.0.10 on Windows 10, so that I have to relogin and put in all data for that. That is really annyoing. (It is only available in my local network).

Is there any way not to remove the account and just reconnect on server availability? I could not find anything in the configs.

I have changed some sensitive pw/paths in the logs/docker-compose. Please let me know if you need any other logs/config/info.

Thank you for your help!

seadrive-gui.log

[09/09/24 01:07:29] request failed for http://XXX.XXX.XXX.XXX:XXXX/api2/auth/ping/: {"detail":"User inactive or deleted"}

[09/09/24 01:07:29] Deleted account http://XXX.XXX.XXX.XXX:XXXX XXX@XXX.XX ce8e1d1

docker-compose.yml

services:
  db:
    image: mariadb:10.11
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=XXX # Required, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
      - MARIADB_AUTO_UPGRADE=1
    volumes:
      - /share/Container/container-station-data/application/seafile/seafile-mysql:/var/lib/mysql  # Required, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net

  memcached:
    image: memcached:1.6.18
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net

  seafile:
    image: seafileltd/seafile-mc:11.0-latest
    container_name: seafile
    ports:
      - "9998:8080"
      - "9999:80"
    volumes:
      - /share/Container/container-station-data/application/seafile/seafile-data:/shared   # Required, specifies the path to Seafile data persistent store.
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=XXX # Required, the value should be root's password of MySQL service.
      - TIME_ZONE=Europe/Berlin  # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=XXX@XXX.io # Specifies Seafile admin user, default is 'me@example.com'.
      - SEAFILE_ADMIN_PASSWORD=XXX# Specifies Seafile admin password, default is 'asecret'.
      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether to use https or not.
      - SEAFILE_SERVER_HOSTNAME=docs.seafile.com # Specifies your host name if https is enabled.
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net

networks:
  seafile-net:
feiniks commented 1 month ago

Hello @phiradd , can you show the seahub.log and seafile.log from the seafile server when the account was deleted?

phiradd commented 1 month ago

@feiniks Sure. Here are the log entry snippets around that time. Thanks for your help.

Seahub.log

2024-09-09 01:07:21,904 [WARNING] django.request:241 log_response Unauthorized: /api2/auth/ping/
2024-09-09 01:07:38,422 [ERROR] django.request:241 log_response Internal Server Error: /api2/account/info/
Traceback (most recent call last):
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/seafile/seafile-server-11.0.12/seahub/seahub/api2/base.py", line 23, in dispatch
    response = super(APIView, self).dispatch(*a, **kw)
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/seafile/seafile-server-11.0.12/seahub/seahub/api2/base.py", line 20, in handle_exception
    return super(APIView, self).handle_exception(exc)
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/rest_framework/views.py", line 497, in dispatch
    self.initial(request, *args, **kwargs)
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/rest_framework/views.py", line 414, in initial
    self.perform_authentication(request)
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/rest_framework/views.py", line 324, in perform_authentication
    request.user
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/rest_framework/request.py", line 227, in user
    self._authenticate()
  File "/opt/seafile/seafile-server-11.0.12/seahub/thirdpart/rest_framework/request.py", line 380, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/opt/seafile/seafile-server-11.0.12/seahub/seahub/api2/authentication.py", line 67, in authenticate
    ret = self.authenticate_v2(request, key)
  File "/opt/seafile/seafile-server-11.0.12/seahub/seahub/api2/authentication.py", line 103, in authenticate_v2
    user = User.objects.get(email=token.user)
  File "/opt/seafile/seafile-server-11.0.12/seahub/seahub/base/accounts.py", line 280, in get
    emailuser = ccnet_threaded_rpc.get_emailuser(email)
  File "/opt/seafile/seafile-server-11.0.12/seafile/lib/python3/site-packages/pysearpc/client.py", line 125, in newfunc
    ret_str = self.call_remote_func_sync(fcall_str)
  File "/opt/seafile/seafile-server-11.0.12/seafile/lib/python3/site-packages/pysearpc/named_pipe.py", line 98, in call_remote_func_sync
    ret_str = transport.send(self.service_name, fcall_str)
  File "/opt/seafile/seafile-server-11.0.12/seafile/lib/python3/site-packages/pysearpc/named_pipe.py", line 62, in send
    resp_header = recvall(self.pipe, 4)
  File "/opt/seafile/seafile-server-11.0.12/seafile/lib/python3/site-packages/pysearpc/utils.py", line 17, in recvall
    raise NetworkError("Failed to read from socket")
pysearpc.errors.NetworkError: Failed to read from socket

seafile.log

2024-09-09 01:06:22 ../common/seaf-db.c(867): Failed to connect to MySQL: Unknown server host 'db' (-3)
2024-09-09 01:06:23 http-server.c(2714): DB error when get accessible repo list.
2024-09-09 01:06:35 ../common/seaf-db.c(867): Failed to connect to MySQL: Lost connection to server at 'handshake: reading initial communication packet', system error: 110
2024-09-09 01:07:00 ../common/seaf-db.c(867): Failed to connect to MySQL: Lost connection to server at 'handshake: reading initial communication packet', system error: 110
2024-09-09 01:07:01 http-server.c(2714): DB error when get accessible repo list.
2024-09-09 01:07:12 ../common/seaf-db.c(867): Failed to connect to MySQL: Lost connection to server at 'reading authorization packet', system error: 110
2024-09-09 01:07:12 ../common/seaf-db.c(867): Failed to connect to MySQL: Lost connection to server at 'reading authorization packet', system error: 110
2024-09-09 01:07:13 repo-mgr.c(3810): Failed to add branch.
2024-09-09 01:07:13 http-server.c(2714): DB error when get accessible repo list.
2024-09-09 01:07:15 seafile-session.c(631): Failed to create system default repo.
2024-09-09 01:07:15 start to serve on pipe client
2024-09-09 01:07:15 start to serve on pipe client
2024-09-09 01:07:19 ../common/seaf-db.c(867): Failed to connect to MySQL: Lost connection to server at 'handshake: reading initial communication packet', system error: 110
2024-09-09 01:07:20 ../common/seaf-db.c(867): Failed to connect to MySQL: Lost connection to server at 'handshake: reading initial communication packet', system error: 110
2024-09-09 01:07:21 ../common/seaf-db.c(867): Failed to connect to MySQL: Lost connection to server at 'handshake: reading initial communication packet', system error: 110
2024-09-09 01:07:35 ../common/seaf-db.c(928): Failed to prepare sql SELECT e.id, e.email, is_staff, is_active, ctime, passwd, reference_id, role  FROM EmailUser e LEFT JOIN UserRole ON e.email = UserRole.email  WHERE e.email=?: Lost connection to server during query
2024-09-09 01:07:37 ../common/seaf-db.c(501): The mysql connection has expired, creating a new connection to re-query.
2024-09-09 01:10:47 seafile-session.c(65): fileserver: web_token_expire_time = 3600
2024-09-09 01:10:47 seafile-session.c(65): fileserver: web_token_expire_time = 3600
2024-09-09 01:10:48 seafile-session.c(77): fileserver: max_index_processing_threads= 3
2024-09-09 01:10:48 seafile-session.c(77): fileserver: max_index_processing_threads= 3
feiniks commented 1 month ago

Hello @phiradd , based on the logs, it seems this error occurred due to a database disconnection. Since the database could not be reached, the system was unable to verify the user's existence, resulting in a 401 response. The failure to connect to the database was likely caused by the NAS being unreachable, preventing MySQL from reading the local data. However, a 401 response may not be appropriate in this case, and we will look into optimizing this issue.

phiradd commented 1 month ago

@feiniks Thank you very much for your insights. The db runs on the same NAS as the seafile server. Admittedly, there is probably too much running on the NAS, such that the db did not respond in time for the request as the NAS was busy with other stuff. I will upgrade the NAS eventually. Is there a config where I can increase the timeout for the database connection to make it more likely that this issue does not come up that often?

feiniks commented 1 month ago

Hello @phiradd, the client timeout for MySQL is set to the default and cannot be configured.