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

D1 export api change #6203

Merged
merged 5 commits into from
Jul 19, 2024
Merged

D1 export api change #6203

merged 5 commits into from
Jul 19, 2024

Conversation

geelen
Copy link
Contributor

@geelen geelen commented Jul 5, 2024

What this PR solves / how to test

Internal API change for D1 import/export.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Included
    • Not necessary because: behaviour unchanged
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • Not required because: behaviour unchanged
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Included
    • Not necessary because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Not necessary because: covered by D1 OpenAPI description

@geelen geelen requested review from a team as code owners July 5, 2024 03:49
Copy link

changeset-bot bot commented Jul 5, 2024

🦋 Changeset detected

Latest commit: 18b58c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jul 5, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10011021497/npm-package-wrangler-6203

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6203/npm-package-wrangler-6203

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10011021497/npm-package-wrangler-6203 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10011021497/npm-package-create-cloudflare-6203 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10011021497/npm-package-cloudflare-kv-asset-handler-6203
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10011021497/npm-package-miniflare-6203
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10011021497/npm-package-cloudflare-pages-shared-6203
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10011021497/npm-package-cloudflare-vitest-pool-workers-6203

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240718.0
workerd 1.20240718.0 1.20240718.0
workerd --version 1.20240718.0 2024-07-18

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@petebacondarwin
Copy link
Contributor

As D1 is now GA, I assume that the API cannot be broken by changing the fields that are expected in requests and returned in responses, right? Otherwise previous Wrangler versions will now start failing. Can you confirm this is the case.

@petebacondarwin
Copy link
Contributor

Is there a link to an internal document or ticket describing this API change?

@geelen
Copy link
Contributor Author

geelen commented Jul 8, 2024

Yeah we'll be providing backwards-compatible API request/responses for versions of Wrangler that predate this change being released (based on user-agent). Internal ticket is CFSQL-942.

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

In order for this to trigger a release of Wrangler (and this code) it needs a "patch" changeset.

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Looks like you need to update some tests.

@geelen geelen force-pushed the glen/d1-export-api-change branch from e56b9b6 to 6e4f51f Compare July 11, 2024 01:42
@geelen
Copy link
Contributor Author

geelen commented Jul 11, 2024

@petebacondarwin added changeset and passing all tests

@geelen geelen force-pushed the glen/d1-export-api-change branch from 6e4f51f to 3ecee31 Compare July 11, 2024 07:03
@petebacondarwin
Copy link
Contributor

I tried re-running the CI jobs a number of times and I am seeing lots of OOM errors.
I can't tell if that is due to changes here, a new problem with Wrangler, or just flakes.

@CarmenPopoviciu
Copy link
Contributor

@geelen can you please rebase your changes on top of main and resolve the conflicts? Maybe that fixes the tests failure we're seeing? 🤞

@RamIdeas
Copy link
Contributor

@geelen can you please rebase your changes on top of main and resolve the conflicts? Maybe that fixes the tests failure we're seeing? 🤞

@geelen I rebased from main and resolved the conflicts on your behalf to get a head start on whether that will fix the OOM test failures

@RamIdeas
Copy link
Contributor

RamIdeas commented Jul 19, 2024

Been looking into this OOM test failure.

Even though vitest makes it look like the "should handle local" test is failing it is actually the "should handle remote" test.

And it looks like the code is infinitely calling pollExport recursively in this else-branch https://github.com/cloudflare/workers-sdk/blob/glen/d1-export-api-change/packages/wrangler/src/d1/export.ts#L255 because response.status is "active" not "complete" or "error"

Comment on lines 121 to 130
// This endpoint is polled recursively. If we respond immediately,
// the callstack builds up quickly leading to a hard-to-debug OOM error.
// This timeout ensures that if the endpoint is accidently polled infinitely
// the test will timeout before breaching available memory
await setTimeout(10);

const body = (await request.json()) as Record<string, unknown>;

// First request, initiates a new task
if (!body.currentBookmark) {
if (!body.current_bookmark) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This missed renaming from currentBookmark to current_bookmark was the culprit of the OOM

I have also added a timeout above to avoid this happening in the future. The OOM error was very opaque and hard to debug with many red herrings.

Copy link
Contributor

Choose a reason for hiding this comment

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

u da best Rahul <3!!!

@CarmenPopoviciu CarmenPopoviciu merged commit 5462ead into main Jul 19, 2024
18 checks passed
@CarmenPopoviciu CarmenPopoviciu deleted the glen/d1-export-api-change branch July 19, 2024 16:25
@CarmenPopoviciu
Copy link
Contributor

much awesomeness @RamIdeas 🎸 ! Thx so much for helping out here 🫶 ! @geelen this is now merged! thx both of you for making wrangler better <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants