juicedata/juicefs · error

get delslices %d

Error message

get delslices %d

What it means

In scanTrashSlices (run by `juicefs gc` trash slice cleanup), each delayed-slices row is re-read inside a transaction before cleanup. If the SELECT of the delslices row by Id fails at the database level, the error is wrapped as "get delslices %d" and gc stops for that row.

Source

Thrown at pkg/meta/sql.go:4064

			return err
		} else if !ok {
			return nil
		}
		return tx.Find(&dss)
	})
	if err != nil {
		return err
	}
	var ss []Slice
	for _, ds := range dss {
		var claimed bool
		err = m.txn(func(tx *xorm.Session) error {
			claimed = false
			ss = ss[:0]
			del := delslices{Id: ds.Id}
			found, err := tx.Get(&del)
			if err != nil {
				return errors.Wrapf(err, "get delslices %d", ds.Id)
			}
			if !found {
				return nil
			}
			m.decodeDelayedSlices(del.Slices, &ss)
			clean, err := scan(ss, del.Deleted)
			if err != nil {
				return err
			}
			if !clean {
				return nil
			}

			// Deleting the delayed row claims cleanup; rollback restores it on failure.
			affected, err := tx.Delete(&delslices{Id: del.Id})
			if err != nil {
				return errors.Wrapf(err, "claim delayed slice %d", del.Id)
			}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Re-run `juicefs gc`; the scan is resumable since rows are processed one by one
  2. Increase DB connection/idle timeouts or use a more stable direct connection
  3. Check the wrapped cause for lock waits and run gc during low-traffic windows
  4. If a specific row is corrupt, verify table integrity (CHECK TABLE / VACUUM)
Defensive patterns

Strategy: retry

Validate before calling

// check DB reachability before a long gc run
db.Ping()

Try / catch

if err != nil && strings.Contains(err.Error(), "get delslices") {
    // transient DB failure: wait and re-run `juicefs gc`
}

Prevention

When it happens

Trigger: `juicefs gc --delete-slices` (or trash slice scan) on a SQL volume while re-reading a delslices row, and the underlying SELECT fails due to connection loss, lock wait timeout, or table corruption.

Common situations: Long-running gc against MySQL/Postgres with connection idle timeouts; DB failover mid-scan; heavy write load causing lock waits; proxy/LB dropping long transactions.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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