-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAT-13871] Support deletion of databases in DB scoped DR config
Summary: Allow users to delete databases to the DR config after enabled DB scoped replication on YBA. Users can enable this feature by enabling the yb.xcluster.db_scoped.enabled runtime flag. Currently supports deletion of databases without bootstrapping. Example of the setDatbases API: ``` curl --location --request PUT 'localhost:9000/api/v1/customers/f33e3c9b-75ab-4c30-80ad-cba85646ea39/dr_configs/a4f7f7cb-0206-4385-82bc-8413f09b1fca/set_dbs' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'X-AUTH-YW-API-TOKEN: XYZ' \ --data '{ "databases": [ "00004004000030008000000000000000", "00004005000030008000000000000000" ] }' ``` Any database that is not in the list of databases in the payload above will be removed from replication. Test Plan: Added UT Create a source and target universe with db version >= 2.23.0.0-b247. Create database `trial1` and `trial2` on both source and target universe Add the following table to the `trial1` and `trial2` db on both source and target universe without any data in it. ``` CREATE TABLE house( ID INT PRIMARY KEY NOT NULL, LOCATION TEXT NOT NULL ); ``` Make a call to the setDatabases endpoint with dbScoped boolean set as true passing both the databases `trial1` and `trial2`. Make sure that the task succeeds. Add data to the table on the source and check that it reflects on the target in both the databases `trial1` and `trial2`. Now, make a call to the setDatabases endpoint with dbScoped boolean set as true passing only the database `trial1`. This will remove replication for the database `trial2`. Now, add some data to the table on the source in the database `trial2` and verify that the data won't be replicated. However, it will be replicated in the database `trial1`. Reviewers: #yba-api-review!, cwang, hzare, daniel, amindrov, sanketh Reviewed By: cwang Subscribers: hsunder, yugaware, cwang, hzare, amindrov, jmak, sanketh Differential Revision: https://phorge.dev.yugabyte.com/D35798
- Loading branch information
Showing
73 changed files
with
787 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...c/main/java/org/yb/client/XClusterRemoveNamespaceFromOutboundReplicationGroupRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) YugaByte, Inc. | ||
|
||
package org.yb.client; | ||
|
||
import com.google.protobuf.Message; | ||
import io.netty.buffer.ByteBuf; | ||
import org.yb.annotations.InterfaceAudience; | ||
import org.yb.master.MasterReplicationOuterClass; | ||
import org.yb.master.MasterTypes.MasterErrorPB; | ||
import org.yb.util.Pair; | ||
|
||
@InterfaceAudience.Public | ||
public class XClusterRemoveNamespaceFromOutboundReplicationGroupRequest | ||
extends YRpc<XClusterRemoveNamespaceFromOutboundReplicationGroupResponse> { | ||
|
||
private final String replicationGroupId; | ||
private final String namespaceId; | ||
|
||
public XClusterRemoveNamespaceFromOutboundReplicationGroupRequest( | ||
YBTable table, String replicationGroupId, String namespaceId) { | ||
super(table); | ||
this.replicationGroupId = replicationGroupId; | ||
this.namespaceId = namespaceId; | ||
} | ||
|
||
@Override | ||
ByteBuf serialize(Message header) { | ||
assert header.isInitialized(); | ||
final MasterReplicationOuterClass.XClusterRemoveNamespaceFromOutboundReplicationGroupRequestPB | ||
.Builder | ||
builder = | ||
MasterReplicationOuterClass.XClusterRemoveNamespaceFromOutboundReplicationGroupRequestPB | ||
.newBuilder(); | ||
builder.setReplicationGroupId(this.replicationGroupId); | ||
builder.setNamespaceId(this.namespaceId); | ||
return toChannelBuffer(header, builder.build()); | ||
} | ||
|
||
@Override | ||
String serviceName() { | ||
return MASTER_SERVICE_NAME; | ||
} | ||
|
||
@Override | ||
String method() { | ||
return "XClusterRemoveNamespaceFromOutboundReplicationGroup"; | ||
} | ||
|
||
@Override | ||
Pair<XClusterRemoveNamespaceFromOutboundReplicationGroupResponse, Object> deserialize( | ||
CallResponse callResponse, String tsUUID) throws Exception { | ||
final MasterReplicationOuterClass.XClusterRemoveNamespaceFromOutboundReplicationGroupResponsePB | ||
.Builder | ||
builder = | ||
MasterReplicationOuterClass. | ||
XClusterRemoveNamespaceFromOutboundReplicationGroupResponsePB | ||
.newBuilder(); | ||
|
||
readProtobuf(callResponse.getPBMessage(), builder); | ||
final MasterErrorPB error = builder.hasError() ? builder.getError() : null; | ||
|
||
XClusterRemoveNamespaceFromOutboundReplicationGroupResponse response = | ||
new XClusterRemoveNamespaceFromOutboundReplicationGroupResponse( | ||
deadlineTracker.getElapsedMillis(), tsUUID, error); | ||
return new Pair<>(response, error); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.../main/java/org/yb/client/XClusterRemoveNamespaceFromOutboundReplicationGroupResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) YugaByte, Inc. | ||
|
||
package org.yb.client; | ||
|
||
import org.yb.annotations.InterfaceAudience; | ||
import org.yb.master.MasterTypes.MasterErrorPB; | ||
|
||
@InterfaceAudience.Public | ||
public class XClusterRemoveNamespaceFromOutboundReplicationGroupResponse extends YRpcResponse { | ||
private final MasterErrorPB error; | ||
|
||
public XClusterRemoveNamespaceFromOutboundReplicationGroupResponse( | ||
long elapsedMillis, String tsUUID, MasterErrorPB error) { | ||
super(elapsedMillis, tsUUID); | ||
this.error = error; | ||
} | ||
|
||
public boolean hasError() { | ||
return error != null; | ||
} | ||
|
||
public String errorMessage() { | ||
if (error == null) { | ||
return ""; | ||
} | ||
return error.getStatus().getMessage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.