juicedata/juicefs · error

max inode

Error message

max inode

What it means

dbMeta.dumpNodes (pkg/meta/sql_bak.go:154) wraps the failure of the `SELECT max(inode) ... WHERE inode < TrashInode` query as "max inode". This query establishes the upper bound for batched dumping of regular (non-trash) nodes during `juicefs dump`.

Source

Thrown at pkg/meta/sql_bak.go:154

		m.parseAttr(&n, &attr)
		pn.Data = m.marshal(&attr)
		nodes = append(nodes, pn)
	}
	if err := dumpResult(ctx, ch, &dumpedResult{&pb.Batch{Nodes: nodes}, release}); err != nil {
		return errors.Wrap(err, "dump trash nodes")
	}

	var maxInode uint64
	err := m.execTxn(ctx, func(s *xorm.Session) error {
		var row node
		ok, err := s.Select("max(inode) as inode").Where("inode < ?", TrashInode).Get(&row)
		if ok {
			maxInode = uint64(row.Inode)
		}
		return err
	})
	if err != nil {
		return errors.Wrap(err, "max inode")
	}

	return sqlQueryBatch(ctx, opt, maxInode, func(ctx context.Context, start, end uint64) (int, error) {
		var rows []node
		if err := m.execTxn(ctx, func(s *xorm.Session) error {
			return s.Where("inode >= ? AND inode < ?", start, end).Find(&rows)
		}); err != nil {
			return 0, err
		}
		nodes := make([]*pb.Node, 0, len(rows))
		var attr Attr
		for _, n := range rows {
			pn := pool.Get().(*pb.Node)
			pn.Inode = uint64(n.Inode)
			m.parseAttr(&n, &attr)
			pn.Data = m.marshal(&attr)
			nodes = append(nodes, pn)
		}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Read the wrapped cause: test connectivity to the metadata DB (`juicefs status <meta-url>`) and re-run the dump.
  2. Check DB server logs for the failing query (timeout/lock wait); raise timeouts or run the dump off-peak.
  3. For SQLite, ensure no other process holds a write lock on the .db file; for MySQL/PG, verify the juicefs_* node table exists and is intact (run `juicefs fsck`).
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight: verify the metadata DB is reachable
status, err := juicefsStatus(metaURL)
if err != nil { return fmt.Errorf("metadata engine unreachable: %w", err) }

Try / catch

if err := dumpMeta(); err != nil {
    if strings.Contains(err.Error(), "max inode") {
        // inspect wrapped DB error; check connectivity/locks, then retry
    }
}

Prevention

When it happens

Trigger: Running `juicefs dump` on a SQL metadata engine when the max-inode query fails: DB connection error, query timeout, table missing/corrupt, or transaction abort inside execTxn.

Common situations: Metadata database under heavy load or failover during a dump; wrong credentials/network to MySQL/PostgreSQL mid-run; SQLite file locked by another process; schema corruption after a failed upgrade.

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/3ebf253e54bcc167. Report an issue: GitHub.