Skip to content

Stream status on postgres - #38716

Merged
Xiaohan Song (xiaohansong) merged 59 commits into
masterfrom
xiaohan/postgresstream
May 29, 2024
Merged

Xiaohan Song (xiaohansong) merged 59 commits into
masterfrom
xiaohan/postgresstream

Conversation

@xiaohansong

@xiaohansong Xiaohan Song (xiaohansong) commented May 28, 2024 •

Copy link
Copy Markdown
Contributor

What

Source postgres will now send start and complete stream status

How

Review guide

User Impact

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

@octavia-squidington-iii Octavia Squidington III (octavia-squidington-iii) added area/documentation Improvements or additions to documentation and removed CDK Connector Development Kit labels May 28, 2024
Xiaohan Song added 2 commits May 28, 2024 14:07
@octavia-squidington-iii Octavia Squidington III (octavia-squidington-iii) added the CDK Connector Development Kit label May 28, 2024
@xiaohansong Xiaohan Song (xiaohansong) changed the title Xiaohan/postgresstream Stream status on postgres May 28, 2024
@xiaohansong
Xiaohan Song (xiaohansong) marked this pull request as ready for review May 28, 2024 21:45
@xiaohansong
Xiaohan Song (xiaohansong) requested a review from a team as a code owner May 28, 2024 21:45

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remember to publish the new CDK and bump cdk version + add to changelog


if (initialSyncCtidIterators.isEmpty()) {
return Collections.singletonList(incrementalIteratorSupplier.get());
return Stream.of(Collections.singletonList(incrementalIteratorSupplier.get()), allStreamsCompleteStatusEmitters).flatMap(Collection::stream)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you will miss here emitting STARTED to incremental streams that are already in CDC sync.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! Fixed and added a test

# See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference)
# for more information about how to configure these tests
connector_image: airbyte/source-postgres:dev
test_strictness_level: high

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious: why do we remove this line? what tests would fail with this level of strictness?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It runs basic_read in this acceptance test but we need to remove it since this connector won't pass it as of today. with this line setting strictness level high, it requires us to have basic_read test enabled. So we'll have to remove this line too.


final List<AutoCloseableIterator<AirbyteMessage>> initialSyncCtidIterators = new ArrayList<>(ctidHandler.getInitialSyncCtidIterator(
new ConfiguredAirbyteCatalog().withStreams(finalListOfStreamsToBeSyncedViaCtid), tableNameToTable, emittedAt));
new ConfiguredAirbyteCatalog().withStreams(finalListOfStreamsToBeSyncedViaCtid), tableNameToTable, emittedAt, true, true));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better to declare those two booleans values as (global) constant variables and pass them to the function for better readability:

static final boolean USE_START_STATUS = true;
static final boolean USE_COMPLETE_STATUS = true;
ctidHandler.getInitialSyncCtidIterator(..., USE_START_STATUS, USE_COMPLETE_STATUS); 

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added inline comment instead - since USE_START_STATUS or USE_COMPLETE_STATUS can be true or false in different scenarios. For readability purpose it's probably more clear to have readers know what that true or false stands for.

cursorBasedCtidHandler.getInitialSyncCtidIterator(new ConfiguredAirbyteCatalog().withStreams(finalListOfStreamsToBeSyncedViaCtid),
tableNameToTable,
emittedAt));
emittedAt, true, true));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.


initialSyncCtidIterators.addAll(ctidHandler.getInitialSyncCtidIterator(
new ConfiguredAirbyteCatalog().withStreams(finalListOfStreamsToBeSyncedViaCtid), tableNameToTable, emittedAt));
new ConfiguredAirbyteCatalog().withStreams(finalListOfStreamsToBeSyncedViaCtid), tableNameToTable, emittedAt, true, false));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

ctidHandler.getInitialSyncCtidIterator(
          new ConfiguredAirbyteCatalog().withStreams(finalListOfStreamsToBeSyncedViaCtid), tableNameToTable, emittedAt, USE_START_STATUS, !USE_COMPLETE_STATUS)

@xiaohansong
Xiaohan Song (xiaohansong) merged commit b104667 into master May 29, 2024
@xiaohansong
Xiaohan Song (xiaohansong) deleted the xiaohan/postgresstream branch May 29, 2024 20:05
Xiaohan Song (xiaohansong) pushed a commit that referenced this pull request May 29, 2024
Co-authored-by: Rodi Reich Zilberman <867491+rodireich@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — d51f7e0b Deployed May 29, 2024 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/connectors Connector related issues area/documentation Improvements or additions to documentation CDK Connector Development Kit connectors/source/postgres

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants