Memcached problems(?)


Hi Jonathan,
it’s just:

enabled = true
memcached_options = --SERVER= --POOL-MIN=10 --POOL-MAX=100

Regards, Moritz


We tried similar setup (CACHES = {…} in, but with haproxy instead of heartbeat. Thus sefaile nodes has always one IP to access memcached. The configuration seems to be stable, but seahub.log of other nodes is full of following exceptions:

2018-02-14 16:38:20,674 [ERROR] django.pylibmc:125 add MemcachedError: memcached_behavior_set returned 38 
for behavior 'remove_failed' = 0
Traceback (most recent call last):
 File "/usr/local/lib/python2.7/dist-packages/django_pylibmc/", line 117, in add
   return self._cache.add(key, value,
 File "/usr/local/lib/python2.7/dist-packages/django_pylibmc/", line 93, in _cache
   client.behaviors = self._options
 File "/usr/local/lib/python2.7/dist-packages/pylibmc/", line 197, in set_behaviors
   return super(Client, self).set_behaviors(_behaviors_numeric(behaviors))
Error: memcached_behavior_set returned 38 for behavior 'remove_failed' = 0

Do you have same errors? Can we just ignore them?


I suggest for single memcache server, all the options be removed.

I suspect that ketama hashing should be used together with remove_failed=1​


I agree with Daniel that the above configuration should be removed from

@schlarbm you observed “marked dead” because “remove_failed” and “ketama” option are hard coded in the C code right now. We will change this and also change the documentation too. (BTW, after some testing, I find that adding --RETRY-TIMEOUT=1 to seafile.conf would also avoid the “marked dead” situation too. But I prefer not to recommend to adding one more option to the config file.)

At last, the memcached config in seafile.conf should be:

enabled = true
memcached_options = --SERVER=ip --POOL-MIN=10 --POOL-MAX=100

in should be

    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': ['ip:11211'],


Hi Jonathan!

Ah, okay!

The two snippets you posted are exactly what we currently have - and apart from that one instance there are no problems at the moment.

We wish you a happy new year holiday!


@vmakarenko Have you solved your memcached issue with the new configuration?


We changed to memcached/keepalived solution. The setup works stable if keepalived points to one memcached instance. But we have similar issues if keepalived switches to backup memcached instance or goes back to master. Seafile cannot recover from this status: seafile server complains about Bad Access Token on background task server or nodes send empty urls to it. The only complete restart of all infrastucture (app nodes + background task server) fixes the problem. Shell I send our confs?


Hi @vmakarenko

Please provide the following config options:

  • [cluster] section in seafile.conf
  • CACHE option in
  • keepalived configuration for migrating memcached VIP

Please also provide the error messages in seafile.log when you switch over the memcached server.

By the way, have you confirmed that the VIP has been migrated to the stand-by memcached server when the main server is shutdown?


enabled = true
memcached_options = --SERVER=V_IP:11211 --POOL-MIN=10 --POOL-MAX=100
health_check_port = 11001

CACHES = {                                                                       
    'default': {                                                                 
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',                      
        'LOCATION': 'V_IP:11211',                                     

keepalived.conf at any of 2 MEMCACHED instances, the only difference: priority 200, 101, 100

lobal_defs {
   notification_email {
   notification_email_from SYSADMIN_EMAIL
   smtp_server localhost
   smtp_connect_timeout 30
   vrrp_garp_interval 5
   vrrp_garp_master_delay 5
   vrrp_garp_master_repeat 5

vrrp_script check_memcached {
   script  "/usr/lib/nagios/plugins/ -H localhost"
   interval 2  # check every 2 seconds
   fall 2  # require 2 failures for KO
   rise 2  # require 2 successes for OK

vrrp_instance memcached {
    state MASTER
    interface eth0
    virtual_router_id 56
    priority 200
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass PASSWORD
   unicast_peer {

    virtual_ipaddress {
    track_script {
    notify /usr/local/bin/

We checked VIP switching: completely fine with the keepalived settings.

seafile-background-tasks.log at background tatsks server after switching of MEMCACHED instance with keepalived:

[2018-03-05 16:48:39,688] [WARNING] failed to fetch document of task  ( HTTP Error 400: Bad Request
"Bad access token"


Hi @vmakarenko

Please have a try this test package:

The config in and seafile.conf need not be changed.

SeafileDocs: a special edition of Seafile that focus on online document and knowledge management

Thank you Jonathan, we will test the package. BTW, I am just cuirious, what has been fixed/changed?


We have removed the hard coded ‘ketama’ and ‘remove_failed’ options in seaf-server. I think your error when switching memcached instances was caused by these options. It doesn’t mean there won’t be any error, but it should recover by itself after the switch is done.


Hi all,

The fix has been included in 6.2.11. New configuration for memcached and Seafile can be found in Just search for “memcached configuration”.


Redis will be supported soon?