Skip to content

Conversation

@tezc
Copy link
Owner

@tezc tezc commented Jun 18, 2025

dummy impl for the cluster plugin api

/* API for implementation/plugin
 *
 * - On destination side, implementation calls clusterAsmRequest(ASM_REQUEST_IMPORT_START)
 *   to start the import operation
 * - Redis calls clusterAsmOnEvent() when an event occurs.
 * - On the source side, Redis will call clusterAsmOnEvent(ASM_EVENT_MIGRATE_WAIT_PAUSE)
 *   when the write pause is needed.
 * - Implementation stops the traffic to the slots and calls clusterAsmRequest(ASM_REQUEST_MIGRATE_PAUSED)
 * - On the destination side, Redis calls clusterAsmOnEvent(ASM_EVENT_IMPORT_WAIT_FINALIZE)
 *   when the import is completed.
 * - Plugin calls clusterAsmRequest(ASM_REQUEST_CONFIG_UPDATED) to notify Redis
 *   that the config is updated.
 *
 * Sequence diagram for import:
 *   - Note: shows only the events that plugin needs to react.
 *
 * ┌───────────────┐              ┌───────────────┐         ┌───────────────┐             ┌───────────────┐
 * │ Destination   │              │ Destination   │         │    Source     │             │ Source        │
 * │ Cluster plugin│              │ Master        │         │    Master     │             │ Cluster plugin│
 * └───────┬───────┘              └───────┬───────┘         └───────┬───────┘             └───────┬───────┘
 *         │                              │                         │                             │
 *         │ ASM_REQUEST_IMPORT_START     │                         │                             │
 *         ├─────────────────────────────►│                         │                             │
 *         │                              │CLUSTER SYNCSLOTS <arg>  │                             │
 *         │                              ├────────────────────────►│                             │
 *         │                              │                         │                             │
 *         │                              │  SNAPSHOT(restore cmds) │                             │
 *         │                              │◄────────────────────────┤                             │
 *         │                              │  Repl stream            │                             │
 *         │                              │◄────────────────────────┤                             │
 *         │                              │                         │ASM_EVENT_MIGRATE_WAIT_PAUSE │
 *         │                              │                         ├────────────────────────────►│
 *         │                              │                         │ ASM_REQUEST_MIGRATE_PAUSED  │
 *         │                              │                         │◄────────────────────────────┤
 *         │                              │ Drain repl stream       │                             │
 *         │                              │◄────────────────────────┤                             │
 *         │ASM_EVENT_IMPORT_WAIT_FINALIZE│                         │                             │
 *         │◄─────────────────────────────┤                         │                             │
 *         │                              │                         │                             │
 *         │ ASM_REQUEST_CONFIG_UPDATED   │                         │                             │
 *         ├─────────────────────────────►│                         │ ASM_REQUEST_CONFIG_UPDATED  │
 *         │                              │                         │◄────────────────────────────┤
 *         │                              │                         │                             │
 */

@tezc tezc marked this pull request as ready for review June 19, 2025 08:49
@tezc tezc requested a review from ShooterIT June 19, 2025 10:02
@ShooterIT
Copy link
Collaborator

cool job, your code makes the responsibilities and interactions between the plugin and redis much clearer to me!

@tezc tezc merged commit 37bb72d into cluster-asm Jun 24, 2025
29 checks passed


/* Called when an ASM event occurs to notify implementation/plugin. */
int clusterAsmOnEvent(slotRangeArray *slot_ranges, int event, void *arg);
Copy link
Owner Author

@tezc tezc Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: Please review last version in cluster-asm branch.

@jhershberg please comment if the above api makes sense.

Some notes/concerns:

  • The above API uses two functions with different operations. So far, it seemed good enough but I wonder if an operation would need to pass more arguments. Then, we may prefer to switch to function calls per operation.
  • I see that plugin handles sds already. So, I assume we can pass strings/errors as sds. Plugin should implement struct slotRangeArray and struct slotRange.
  • For the above API, task identificator is the slot ranges. So, we are not using another kind of an ID, say a sequential integer, but this is how it will be for OSS. We don't have identificator there as well, operator will distinguish operations based on slot ranges.
  • I totally ignored the case the plugin will work on its own thread, please comment if we need adjustment for it.

@tezc tezc deleted the cluster-asm-api-first branch June 30, 2025 23:30
tezc added a commit that referenced this pull request Sep 10, 2025
cluster asm api
tezc added a commit that referenced this pull request Sep 16, 2025
cluster asm api
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants