// Redis error reference

ASK: The key is migrating to another node

The key's slot is being moved to another node: re-send there once, prefixed with ASKING, while the migration finishes.

Error prefix
ASK
카테고리
Cluster and replication
오류 메시지
ASK 12182 127.0.0.1:7002

의미

ASK looks like MOVED but means something narrower: this node still owns the slot, but the key you asked for is being migrated to another node right now, and that node is its temporary home. The client is expected to re-send the command to the target, preceded by an ASKING command, for this one request only.

The distinction matters: MOVED updates the client's slot map permanently, while ASK must not, because the slot still belongs to the source node for every other key. You meet ASK mainly while a resharding job is running (redis-cli --cluster reshard) or during a slot import, and clients handle it themselves. Seeing it by hand usually means you are mid-migration on a test cluster.

일반적인 원인

  • A resharding job is moving the key's slot from this node to another one.
  • A migration was started and interrupted, leaving the slot flagged MIGRATING.
  • A hand-rolled or naive client does not send ASKING after an ASK redirect, so the target refuses the follow-up.

Find the cause

redis-cli -p 7000 CLUSTER KEYSLOT foo
redis-cli -p 7000 CLUSTER NODES
# The migrating marker [12182->-...] names the target node
redis-cli -p 7000 CLUSTER COUNTKEYSINSLOT 12182

해결 방법

  1. See the migration state of the slots on this node:

    redis-cli -p 7000 CLUSTER NODES | grep '\['
    # Lines like [12182->-<id>] show slot 12182 migrating to node <id>
  2. By hand, send ASKING before the command on the target node:

    redis-cli -p 7002 ASKING
    # OK
    redis-cli -p 7002 GET foo
  3. Let the reshard finish; it moves the remaining keys and clears the MIGRATING flag:

    redis-cli --cluster reshard 127.0.0.1:7000

Other ways to handle it

For planned moves of live traffic, reshard in a maintenance window; well-behaved clients see a short burst of ASK and MOVED and then a fresh slot map. Hash tags reduce how many keys any one migration disturbs.

안전하게 재현하세요

The ASK reply appears once the key itself has moved while the slot is still marked MIGRATING on the source node.

redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 --cluster-replicas 0
redis-cli -p 7000 SET foo bar
redis-cli -p 7000 CLUSTER SETSLOT 12182 MIGRATING <node-id-of-7002>
redis-cli -p 7000 MIGRATE 127.0.0.1 7002 foo 0 5000
redis-cli -p 7000 GET foo
# (error) ASK 12182 127.0.0.1:7002
redis-cli --cluster reshard 127.0.0.1:7000   # finishing clears the state

질문

ASK or MOVED: when do I update the client's slot map?

On MOVED, permanently: the slot changed owner. On ASK, never: re-send that single request with ASKING and keep using the source node for everything else.

What does ASKING actually do?

It marks the next request on that connection as 'redirected during migration', letting the importing node serve a key whose slot it does not own yet.

관련 오류

More cluster and replication errors

코드와 메시지 텍스트의 출처는 다음과 같습니다 Redis documentation and source code. 전체 목록은 Redis error list 또는 모든 데이터베이스 오류 검색.

// 오류는 줄이고, 수정은 빠르게

Work on Redis in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Redis and the other databases you use.

이 페이지의 텍스트와 데이터: CC BY 4.0, 출처: SQLly (sqlly.app). 코드와 SQL 스니펫: MIT. 라이선스 세부 정보 인용된 오류 메시지 텍스트의 권리는 해당 데이터베이스 공급업체에 있습니다.