{"record":{"id":"b6c667a758f3c1f4","repo":"juicedata/juicefs","slug":"new-session-d-s","errorCode":null,"errorMessage":"new session %d: %s","messagePattern":"new session (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis.go","lineNumber":455,"sourceCode":"\tbody, err := m.rdb.Get(Background(), m.setting()).Bytes()\n\tif err == redis.Nil {\n\t\treturn nil, nil\n\t}\n\treturn body, err\n}\n\nfunc (m *redisMeta) doNewSession(sinfo []byte, update bool) error {\n\tctx := Background()\n\tssid := strconv.FormatUint(m.sid, 10)\n\texpire := m.expireTime()\n\t_, err := m.rdb.TxPipelined(ctx, func(pipe redis.Pipeliner) error {\n\t\tpipe.ZAdd(ctx, m.allSessions(), redis.Z{Score: float64(expire), Member: ssid})\n\t\tpipe.HSet(ctx, m.sessionInfos(), ssid, sinfo)\n\t\tm.genLog(ctx, pipe, time.Now(), \"NEWSESSION(%d,%d,%s)\", m.sid, expire, logEncode(sinfo))\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"new session %d: %s\", m.sid, err)\n\t}\n\n\tif m.shaLookup, err = m.rdb.ScriptLoad(Background(), scriptLookup).Result(); err != nil {\n\t\tlogger.Warnf(\"load scriptLookup: %v\", err)\n\t\tm.shaLookup = \"\"\n\t}\n\tif m.shaResolve, err = m.rdb.ScriptLoad(Background(), scriptResolve).Result(); err != nil {\n\t\tlogger.Warnf(\"load scriptResolve: %v\", err)\n\t\tm.shaResolve = \"\"\n\t}\n\n\tif !m.conf.NoBGJob {\n\t\tgo m.cleanupLegacies()\n\t}\n\treturn nil\n}\n\nfunc (m *redisMeta) getCounter(name string) (int64, error) {","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis.go#L437-L473","documentation":"doNewSession registers the client session in Redis (ZAdd to the session set, HSet of session info, plus a metadata log entry) inside a pipeline; if any of these Redis commands fail, the whole operation is wrapped as \"new session %d: %s\" (pkg/meta/redis.go:455). A failed session registration means the client cannot join the volume's session tracking, so mount/init aborts.","triggerScenarios":"Any Redis failure during the session-registration pipeline: connection refused/timeout, READONLY replica (writes not allowed), OOM/NOAUTH/CLUSTERDOWN errors, cluster MOVED errors, or a failover in progress when a client starts up.","commonSituations":"Pointing the client at a read-only replica instead of the master; Redis cluster failover or resharding during mount; Redis maxmemory reached; wrong password (NOAUTH); transient network partition between client and Redis.","solutions":["Read the wrapped Redis error in the message and fix its root cause (e.g., connection refused -> verify host/port; NOAUTH -> fix password via REDIS_PASSWORD or the URL).","Ensure you connect to the master, not a read-only replica (check with redis-cli INFO replication).","If using Redis Cluster, connect via the cluster-aware URL so MOVED redirects are handled.","Check Redis memory limits (maxmemory policy) and free memory or raise the limit.","Retry the mount after a transient failover/network blip."],"exampleFix":"// before\njuicefs mount redis://replica-host:6379/1 /mnt/jfs\n// new session 1: READONLY You can't write against a read only replica.\n// after: point at the master\njuicefs mount redis://master-host:6379/1 /mnt/jfs","handlingStrategy":"retry","validationCode":"// before mounting, verify the Redis endpoint accepts writes\nif err := rdb.Ping(ctx).Err(); err != nil {\n    return fmt.Errorf(\"redis not reachable: %w\", err)\n}\nif role, _ := rdb.Do(ctx, \"ROLE\").String(); strings.Contains(role, \"slave\") {\n    return errors.New(\"endpoint is a read-only replica; use the master\")\n}","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n    err := tryMount(redisURL)\n    if err == nil || !strings.Contains(err.Error(), \"new session \") {\n        return err\n    }\n    time.Sleep(time.Duration(1<<attempt) * time.Second) // transient failover/network blip\n}\nreturn errors.New(\"session registration kept failing; check Redis health\")","preventionTips":["Always point clients at the Redis master, never a read-only replica.","Monitor Redis maxmemory and set an eviction/appropriate policy.","Use the cluster-aware URL scheme for Redis Cluster so redirects are followed.","Ensure the password is set (REDIS_PASSWORD or URL) to avoid NOAUTH at startup."],"tags":["redis","session","network","write-failed"],"backgroundTag":"database-write-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}