Skip to content

Commit 496331f

Browse files
authored
enhance: support alias with WAL-based DDL framework (#44865)
issue: #43897 - Alias related DDL is implemented by WAL-based DDL framework now. - Support following message type in wal AlterAlias, DropAlias. - Alias DDL can be synced by new CDC now. - Refactor some UT for Alias DDL. Signed-off-by: chyezh <[email protected]>
1 parent eae6aff commit 496331f

19 files changed

+720
-899
lines changed

internal/rootcoord/alter_alias_task.go

Lines changed: 0 additions & 54 deletions
This file was deleted.

internal/rootcoord/alter_alias_task_test.go

Lines changed: 0 additions & 78 deletions
This file was deleted.

internal/rootcoord/create_alias_task.go

Lines changed: 0 additions & 98 deletions
This file was deleted.

internal/rootcoord/create_alias_task_test.go

Lines changed: 0 additions & 99 deletions
This file was deleted.

internal/rootcoord/ddl_callbacks.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func RegisterDDLCallbacks(core *Core) {
3838
}
3939
ddlCallback.registerRBACCallbacks()
4040
ddlCallback.registerDatabaseCallbacks()
41+
ddlCallback.registerAliasCallbacks()
4142
}
4243

4344
// registerRBACCallbacks registers the rbac callbacks.
@@ -62,6 +63,12 @@ func (c *DDLCallback) registerDatabaseCallbacks() {
6263
registry.RegisterDropDatabaseV2AckCallback(c.dropDatabaseV1AckCallback)
6364
}
6465

66+
// registerAliasCallbacks registers the alias callbacks.
67+
func (c *DDLCallback) registerAliasCallbacks() {
68+
registry.RegisterAlterAliasV2AckCallback(c.alterAliasV2AckCallback)
69+
registry.RegisterDropAliasV2AckCallback(c.dropAliasV2AckCallback)
70+
}
71+
6572
// DDLCallback is the callback of ddl.
6673
type DDLCallback struct {
6774
*Core
@@ -118,3 +125,16 @@ func startBroadcastWithDatabaseLock(ctx context.Context, dbName string) (broadca
118125
}
119126
return broadcaster, nil
120127
}
128+
129+
// startBroadcastWithAlterAliasLock starts a broadcast with alter alias lock.
130+
func startBroadcastWithAlterAliasLock(ctx context.Context, dbName string, collectionName string, alias string) (broadcaster.BroadcastAPI, error) {
131+
broadcaster, err := broadcast.StartBroadcastWithResourceKeys(ctx,
132+
message.NewSharedDBNameResourceKey(dbName),
133+
message.NewExclusiveCollectionNameResourceKey(dbName, collectionName),
134+
message.NewExclusiveCollectionNameResourceKey(dbName, alias),
135+
)
136+
if err != nil {
137+
return nil, errors.Wrap(err, "failed to start broadcast with alter alias lock")
138+
}
139+
return broadcaster, nil
140+
}

0 commit comments

Comments
 (0)