Coder Social home page Coder Social logo

Comments (1)

StrikeW avatar StrikeW commented on September 26, 2024

We already check whether the slot.name has already existed for postgres-cdc.

try (var stmt =
jdbcConnection.prepareStatement(ValidatorUtils.getSql("postgres.slot.check"))) {
// check whether the replication slot is already existed
stmt.setString(1, slotName);
stmt.setString(2, dbName);
var res = stmt.executeQuery();
if (res.next() && res.getString(1).equals(slotName)) {
LOG.info("replication slot '{}' already exists, just use it", slotName);
} else {
// otherwise, we need to create a new one
var stmt2 =
jdbcConnection.prepareStatement(
ValidatorUtils.getSql("postgres.slot_limit.check"));
var res2 = stmt2.executeQuery();
// check whether the number of replication slots reaches the max limit
if (res2.next() && res2.getString(1).equals("true")) {
throw ValidatorUtils.failedPrecondition(
"all replication slots are in use\n Hint: Free one or increase max_replication_slots.");
}
}

But there is a race condition:
If user creates two postgres sources concurrently with the same slot.name, both sources can pass the validation because the slot doesn't exist indeed. But one of the source job will fail when the source executor start the Debezium connector, due to the duplication of slot.name.

Options:

  • One solution is to limit the concurrency of CREATE SOURCE DDL to 1 to prevent creating multiple PG sources concurrently
  • Maintain a internal cache/table on Meta to do the duplication check

from risingwave.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.