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

Client should push migrations in small batches #1237

Closed
kostasb opened this issue Nov 2, 2023 · 4 comments
Closed

Client should push migrations in small batches #1237

kostasb opened this issue Nov 2, 2023 · 4 comments
Labels
bug Something isn't working needs-triage

Comments

@kostasb
Copy link
Contributor

kostasb commented Nov 2, 2023

Describe the bug
When the client pushes a very large schema (i.e. xata schema upload with >30 tables) it is prone to hitting gateway timeout.

Migrations or schema update operations should be pushed in iterative batches, with a best practice size of no more than 10 operations per request.

Relates to internal issue https://github.com/xataio/xata/issues/3353

@kostasb kostasb added the bug Something isn't working label Nov 2, 2023
@SferaDev
Copy link
Member

SferaDev commented Nov 3, 2023

The ~10 operations is a limitation on the backend with synchronous schema changes. With the integration of pgroll we will be able to do async schema changes, and this won't be an issue.

We cannot chunk the schema, as dependencies should be ordered (for example links, or circular refs). So we won't attempt to fix it client side, and instead wait for the new APIs to land.

@kostasb kostasb closed this as completed Nov 3, 2023
@urso
Copy link
Contributor

urso commented Nov 3, 2023

The idea would be to not push all migration files at once. e.g. only apply up to 10 files per API call. The files should not be split up into operations. But right now if users push many files with many tables in them then the gateway will timeout the operation.

@kostasb kostasb reopened this Nov 3, 2023
@SferaDev
Copy link
Member

SferaDev commented Nov 3, 2023

@urso For this command, we are doing:

    const { edits } = await xata.api.migrations.compareBranchWithUserSchema({
      workspace,
      region,
      database,
      branch,
      schema
    });

    await xata.api.migrations.applyBranchSchemaEdit({ workspace, region, database, branch, edits });

So it's very tricky to try to manipulate the backend suggested edits.

@urso
Copy link
Contributor

urso commented Nov 3, 2023

I see.

@kostasb kostasb closed this as completed Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

3 participants