Skip to content

Commit

Permalink
DBZ-7308 tableLockingStatement from SnapshotLock interface now takes …
Browse files Browse the repository at this point in the history
…just one table in input
  • Loading branch information
mfvitale authored and jpechane committed Mar 25, 2024
1 parent 391eb03 commit e2c4bb8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.sql.Savepoint;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -32,7 +31,6 @@
import io.debezium.relational.Tables;
import io.debezium.schema.SchemaChangeEvent;
import io.debezium.snapshot.SnapshotterService;
import io.debezium.spi.snapshot.Snapshotter;
import io.debezium.util.Clock;

public class Db2SnapshotChangeEventSource extends RelationalSnapshotChangeEventSource<Db2Partition, Db2OffsetContext> {
Expand Down Expand Up @@ -90,7 +88,7 @@ else if (connectorConfig.getSnapshotIsolationMode() == SnapshotIsolationMode.EXC
}

Optional<String> lockingStatement = snapshotterService.getSnapshotLock().tableLockingStatement(connectorConfig.snapshotLockTimeout(),
Set.of(quoteTableName(tableId)));
quoteTableName(tableId));

if (lockingStatement.isPresent()) {
LOGGER.info("Locking table {}", tableId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import io.debezium.connector.db2.Db2ConnectorConfig;
import io.debezium.snapshot.spi.SnapshotLock;
Expand All @@ -26,9 +25,7 @@ public void configure(Map<String, ?> properties) {
}

@Override
public Optional<String> tableLockingStatement(Duration lockTimeout, Set<String> tableIds) {

String tableId = tableIds.iterator().next(); // For Db2 we expect just one table at time.
public Optional<String> tableLockingStatement(Duration lockTimeout, String tableId) {

return Optional.of("SELECT * FROM " + tableId + " WHERE 0=1 WITH CS");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import io.debezium.connector.db2.Db2ConnectorConfig;
import io.debezium.snapshot.spi.SnapshotLock;
Expand All @@ -26,7 +25,7 @@ public void configure(Map<String, ?> properties) {
}

@Override
public Optional<String> tableLockingStatement(Duration lockTimeout, Set<String> tableIds) {
public Optional<String> tableLockingStatement(Duration lockTimeout, String tableId) {

return Optional.empty();
}
Expand Down

0 comments on commit e2c4bb8

Please sign in to comment.