juicedata/juicefs · error

find sustained %d: %s

Error message

find sustained %d: %s

What it means

Thrown by dbMeta.getSession (detail mode) when querying the `sustained` table for files held open by the session fails. GetSession with detail=true aggregates sustained inodes, flock, and plock rows; a SQL error on the sustained lookup aborts session detail retrieval.

Source

Thrown at pkg/meta/sql.go:849

		info = row.Info
		if info == nil { // legacy client has no info
			info = []byte("{}")
		}
	default:
		return nil, fmt.Errorf("invalid type: %T", row)
	}
	if err := json.Unmarshal(info, &s); err != nil {
		return nil, fmt.Errorf("corrupted session info; json error: %s", err)
	}
	if detail {
		var (
			srows []sustained
			frows []flock
			prows []plock
		)
		err := m.roTxn(Background(), func(ses *xorm.Session) error {
			if err := ses.Find(&srows, &sustained{Sid: s.Sid}); err != nil {
				return fmt.Errorf("find sustained %d: %s", s.Sid, err)
			}
			s.Sustained = make([]Ino, 0, len(srows))
			for _, srow := range srows {
				s.Sustained = append(s.Sustained, srow.Inode)
			}

			if err := ses.Find(&frows, &flock{Sid: s.Sid}); err != nil {
				return fmt.Errorf("find flock %d: %s", s.Sid, err)
			}
			s.Flocks = make([]Flock, 0, len(frows))
			for _, frow := range frows {
				s.Flocks = append(s.Flocks, Flock{frow.Inode, uint64(frow.Owner), string(frow.Ltype)})
			}

			if err := ses.Find(&prows, &plock{Sid: s.Sid}); err != nil {
				return fmt.Errorf("find plock %d: %s", s.Sid, err)
			}
			s.Plocks = make([]Plock, 0, len(prows))

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Read the wrapped %s detail for the underlying SQL driver error and address it.
  2. Verify the sustained table exists and matches the current schema (compare against pkg/meta/sql.go bean definitions).
  3. Reconnect/retry once the database is healthy; session detail queries are read-only and safe to repeat.

Example fix

// before: "find sustained 42: Error 1146: Table 'jfs.sustained' doesn't exist"
// after: restore the table via a full-featured client that auto-creates missing tables, then retry
juicefs status mysql://...   # after re-ensuring schema
Defensive patterns

Strategy: retry

Validate before calling

// verify required tables exist before detail queries
count, err := x.Where("name = 'sustained'").Count(&tables)
if err != nil || count == 0 {
    return fmt.Errorf("sustained table missing")
}

Try / catch

s, err := m.GetSession(sid, true)
if err != nil && strings.Contains(err.Error(), "find sustained") {
    time.Sleep(time.Second)
    s, err = m.GetSession(sid, true) // read-only query, safe to retry
}

Prevention

When it happens

Trigger: `juicefs status <meta-url>` or other session-detail listing while the sustained table is missing/corrupt, the DB connection drops mid read-only transaction, or a lock/timeout occurs on the table.

Common situations: Schema partially migrated (sustained table dropped by an old client's cleanup); MySQL server gone away during a long status listing; table-level corruption on SQLite volumes.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/0e4e5324c0c1ffc0. Report an issue: GitHub.