siyuan-note/siyuan · warning

attribute view order changed; retry the drag

Error message

attribute view order changed; retry the drag

What it means

applyAttributeViewRowOrder commits a drag's new row order using optimistic concurrency: the client sends both the intended RowOrder and the Expected order snapshot it based its drag on. Before applying, the kernel deep-compares the view's actual current row order against Expected. Any mismatch — including a missing RowOrder or Expected — means the view changed since the preview, and the commit is rejected with a retry hint rather than silently overwriting concurrent changes.

Solutions

  1. Re-fetch the attribute view, recompute both expected and rowOrder from the fresh state, and re-apply the drag.
  2. Include non-nil rowOrder and expected objects in the payload — missing fields are treated as a stale commit.
  3. Resolve concurrent edits first (close other editors or wait for sync to settle), then retry.
  4. Keep the time between preview and commit short to minimize the chance of intervening changes.

Example fix

// before
applyRowOrder(avID, { rowOrder: newOrder }) // missing expected
// after
applyRowOrder(avID, { rowOrder: newOrder, expected: getCurrentRowOrderSnapshot(view) })
Defensive patterns

Strategy: retry

Validate before calling

if (!payload.rowOrder || !payload.expected) {
  throw new Error("rowOrder and expected are required for optimistic row-order commit");
}

Try / catch

try {
  await applyAttributeViewRowOrder(payload);
} catch (e) {
  if (String(e.msg).includes("order changed; retry")) {
    const fresh = await fetchAttributeView(avID);
    payload.expected = snapshotRowOrder(fresh);
    // redo the drag/reorder against the fresh state
  }
}

Prevention

When it happens

Trigger: Submitting a row-order change whose Expected snapshot no longer matches the live view: another client modified rows in the meantime, sort values changed so the rendered order differs, or the payload omits rowOrder/expected fields entirely (nil pointers also trigger this error).

Common situations: Two windows open on the same database dragging rows concurrently; a long-lived preview followed by a background change (e.g. sync or another process updating cell values); a plugin constructing the payload but forgetting the expected field.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/8b80dd7f1c095a23. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/attribute_view_row_sort.go:236

			ret = append(ret, id)
			seen[id] = true
		}
	}
	return ret
}

func applyAttributeViewRowOrder(attrView *av.AttributeView, view *av.View, data any) error {
	encoded, err := gulu.JSON.MarshalJSON(data)
	if nil != err {
		return err
	}
	var change attributeViewRowOrderChange
	if err = gulu.JSON.UnmarshalJSON(encoded, &change); nil != err {
		return err
	}
	if nil == change.RowOrder || nil == change.Expected ||
		!reflect.DeepEqual(getAttributeViewRowOrder(view), change.Expected) {
		return errors.New("attribute view order changed; retry the drag")
	}
	if len(change.RowOrder.Groups) != len(view.Groups) {
		return errors.New("attribute view groups changed; retry the drag")
	}
	for _, group := range view.Groups {
		if _, ok := change.RowOrder.Groups[group.ID]; !ok {
			return errors.New("attribute view group not found")
		}
	}
	if nil != change.ValidateGroup && len(change.RowOrder.Sorts) > 0 {
		// 预览之后字段值可能变化,提交时再次校验,不能悄悄接受冲突的落点。
		copyView, copyErr := cloneAttributeViewRowSort(attrView)
		if nil != copyErr {
			return copyErr
		}
		candidate := copyView.GetView(view.ID)
		setAttributeViewRowOrder(candidate, change.RowOrder)
		collections, renderErr := renderAttributeViewRowSortCollections(copyView, candidate, false)

View on GitHub (pinned to 9f775e8a12)