-
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.
Browse files
Browse the repository at this point in the history
Summary: This diff enables the CRUD syntax for Publications in YSQL. This change is part of the project to add a YSQL API for CDC via the PG logical replication mechanism. In PG, a Publication determines which tables should be streamed via logical replication. A user can choose to create a Publication on: 1. All tables of a database 2. All tables of a schema 3. List of tables explicitly provided in the command In YB, a Publication will be equivalent to the configuration of a CDC stream i.e. it will specify which tables the user is interested in streaming via CDC. The information about Publication will be kept in PG system catalog tables and the schema will be **same** as PG: 1. pg_publication: Metadata of a Publication 2. pg_publication_rel: (puboid, reloid) pair for each Publication-Table pair 3. pg_publication_tables: View over pg_publication_rel which expands the list of tables if the Publication was created for all the tables (future) of a database The only difference between the YSQL and PG semantics are due to a few CDC limitations. **Limitations** - CDC does not support choosing a subset of records (insert, update, delete, truncate). So we return an error with `ERRCODE_FEATURE_NOT_SUPPORTED` error code if the user tries to specify that either during `Create` or `Alter` - CDC does not support tables without user defined primary key. This is handled differently depending on whether the Publication is being created on all tables (`FOR ALL TABLES`) or an explicit list (`FOR TABLE t1, t2`) is provided - `FOR ALL TABLES`: These tables are skipped. We also filter them out in the `pg_publication_tables` view - `FOR TABLE t1, t2, ...`: We return an `ERRCODE_FEATURE_NOT_SUPPORTED` error **Upgrade\Rollback safety:** These changes cannot be rolled back. As a result, all the commands are disabled during upgrade using an autoflag `yb_enable_replication_commands` (LocalPersisted) and will only be enabled once the user has committed to the new version. The autoflag is `LocalPersisted` since the YSQL API changes would modify the yb-master sys-catalog information for CDC stream in the future for Replication Slot. So for consistency, we will disable all CDC YSQL API commands during upgrade. Jira: DB-7781, DB-7784, DB-7782 Test Plan: New regress tests `./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPublication'` Reviewers: skumar, aagrawal, asrinivasan, dsrinivasan Reviewed By: dsrinivasan Subscribers: hsunder, jason, yql Differential Revision: https://phorge.dev.yugabyte.com/D28721
- Loading branch information
Showing
18 changed files
with
699 additions
and
9 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgRegressPublication.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,33 @@ | ||
// Copyright (c) YugabyteDB, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed under the License | ||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
package org.yb.pgsql; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.yb.YBTestRunner; | ||
|
||
/** | ||
* Runs the pg_regress publication-related tests on YB code. | ||
*/ | ||
@RunWith(value = YBTestRunner.class) | ||
public class TestPgRegressPublication extends BasePgSQLTest { | ||
@Override | ||
public int getTestMethodTimeoutSec() { | ||
return 1800; | ||
} | ||
|
||
@Test | ||
public void testPgRegressPublication() throws Exception { | ||
runPgRegressTest("yb_publication_schedule"); | ||
} | ||
} |
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
Oops, something went wrong.