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

Destination redshift: async standard inserts #32888

Merged
merged 28 commits into from
Nov 30, 2023

Conversation

edgao
Copy link
Contributor

@edgao edgao commented Nov 28, 2023

closes #32521

  • Add an async version of the jdbc consumer
    • it's a pretty thin wrapper around existing code - almost identical to the non-async consumer
    • Delete the non-async consumer
  • push PartialAirbyteMessage everywhere instead of AirbyteRecordMessage
    • This will be a breaking change in the cdk, but hopefully pretty easy to implement in each destination connector - e.g. redshift gets it almost for free, just a method signature update

I ran a 20M record sync (3 streams of 10M + 10M + 100 records) here https://cloud.airbyte.com/workspaces/b61bc266-ef3c-460c-af2f-f70da4a2993c/connections/3a93c4ec-9b61-42f8-b6f2-4ec052129dfc/job-history#6303716::0; it ran successfully and in approximately the same time as previous syncs. (2hr40min vs older syncs ranging from 2:28 - 3:43)

@edgao edgao requested a review from a team as a code owner November 28, 2023 18:28
Copy link

vercel bot commented Nov 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Nov 30, 2023 4:28pm

@octavia-squidington-iii octavia-squidington-iii added area/connectors Connector related issues CDK Connector Development Kit connectors/destination/redshift labels Nov 28, 2023
Copy link
Contributor

github-actions bot commented Nov 28, 2023

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan.
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • You've updated the connector's metadata.yaml file any other relevant changes, including a breakingChanges entry for major version bumps. See metadata.yaml docs
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • Migration guide updated in docs/integrations/<source or destination>/<name>-migrations.md with an entry for the new version, if the version is a breaking change. See migration guide example
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

@@ -41,4 +42,12 @@ public AirbyteMessageConsumer getConsumer(final JsonNode config,
return destination.getConsumer(config, catalog, outputRecordCollector);
}

@Override
public SerializedAirbyteMessageConsumer getSerializedMessageConsumer(final JsonNode config,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this isn't used by redshift, just adding it since I'm in this part of the code anyway

catalog,
sqlOperations::isValidData);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

every implementation of this method is just return true 🤷 but deleting it looks like a nontrivial refactor so ignoring it for now. It's not used in the async framework at all, and we don't want this functionality to begin with - it's dropping "invalid" records, which we don't want to do.

final String schemaName,
final String tableName)
throws Exception {
dataAdapter.ifPresent(adapter -> records.forEach(airbyteRecordMessage -> adapter.adapt(airbyteRecordMessage.getData())));
dataAdapter.ifPresent(adapter -> records.forEach(airbyteRecordMessage -> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the only DataAdapter in existence is destination-postgres, because of https://airbytehq-team.slack.com/archives/C03C4AVJWG4/p1700605909300539 / #3476

so I don't feel bad about de+reserializing here

// 1-indexed
statement.setString(i, uuidSupplier.get().toString());
statement.setString(i + 1, Jsons.serialize(message.getData()));
statement.setTimestamp(i + 2, Timestamp.from(Instant.ofEpochMilli(message.getEmittedAt())));
statement.setString(i + 1, message.getSerialized());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note that we can skip the Jsons.serialize call here

Copy link
Contributor

@gisripa gisripa left a comment

Choose a reason for hiding this comment

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

lgtm. pending CI tests and connector checklist.

Can you also paste the link of the workspace where you ran large sync for posterity.

@edgao
Copy link
Contributor Author

edgao commented Nov 29, 2023

added a link in the pr description. dest-redshift tests are actually succeeding, we're failing because of source-google-search-console autoformat >.>

@edgao
Copy link
Contributor Author

edgao commented Nov 29, 2023

meh. I'll publish this tomorrow. Either someone else will merge master + fix the format, or I'll just approve-and-merge

(just don't want to release this when I'm about to go on my commute)

@edgao
Copy link
Contributor Author

edgao commented Nov 30, 2023

/publish-java-cdk

🕑 https://github.com/airbytehq/airbyte/actions/runs/7049134047
✅ Successfully published Java CDK version=0.6.0!

@edgao edgao enabled auto-merge (squash) November 30, 2023 16:35
@edgao edgao merged commit 6864074 into master Nov 30, 2023
21 checks passed
@edgao edgao deleted the edgao/redshift/standard_inserts_async branch November 30, 2023 16:54
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/destination/redshift connectors/source/google-search-console
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Redshift insert destination to SerializedAsyncConsumer from BufferedConsumer
4 participants