Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛Source Postgres: xmin query should only happen if user chose that mode #34465

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public class PostgresSource extends AbstractJdbcSource<PostgresType> implements
private Set<AirbyteStreamNameNamespacePair> publicizedTablesInCdc;
private static final Set<String> INVALID_CDC_SSL_MODES = ImmutableSet.of("allow", "prefer");
private int stateEmissionFrequency;
private XminStatus xminStatus;

public static Source sshWrappedSource(PostgresSource source) {
return new SshWrappedSource(source, JdbcUtils.HOST_LIST_KEY, JdbcUtils.PORT_LIST_KEY, "security");
Expand Down Expand Up @@ -273,11 +272,6 @@ protected void logPreSyncDebugData(final JdbcDatabase database, final Configured
indexInfo.close();
}

// Log and save the xmin status
this.xminStatus = PostgresQueryUtils.getXminStatus(database);
LOGGER.info(String.format("Xmin Status : {Number of wraparounds: %s, Xmin Transaction Value: %s, Xmin Raw Value: %s",
xminStatus.getNumWraparound(), xminStatus.getXminXidValue(), xminStatus.getXminRawValue()));

}

@Override
Expand Down Expand Up @@ -483,6 +477,15 @@ public List<AutoCloseableIterator<AirbyteMessage>> getIncrementalIterators(final
}

if (isAnyStreamIncrementalSyncMode(catalog) && PostgresUtils.isXmin(sourceConfig)) {
// Log and save the xmin status
final XminStatus xminStatus;
try {
xminStatus = PostgresQueryUtils.getXminStatus(database);
} catch (SQLException e) {
throw new RuntimeException(e);
}
LOGGER.info(String.format("Xmin Status : {Number of wraparounds: %s, Xmin Transaction Value: %s, Xmin Raw Value: %s",
xminStatus.getNumWraparound(), xminStatus.getXminXidValue(), xminStatus.getXminRawValue()));
final StreamsCategorised<XminStreams> streamsCategorised = categoriseStreams(stateManager, catalog, xminStatus);
final ResultWithFailed<List<AirbyteStreamNameNamespacePair>> streamsUnderVacuum = streamsUnderVacuum(database,
streamsCategorised.ctidStreams().streamsForCtidSync(),
Expand Down
Loading