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

(redshift): upgrading from older CDK version caused This table is already SORTKEY AUTO #26460

Open
mrgrain opened this issue Jul 21, 2023 · 0 comments
Labels
@aws-cdk/aws-redshift Related to Amazon Redshift bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@mrgrain
Copy link
Contributor

mrgrain commented Jul 21, 2023

Describe the bug

In older version of the AWS CDK (pre 2.0.0-alpha.8) setting the sort key was not supported and a created the table did not have an explicit sort key property. When #17135 introduced support for it, the Table Handler got changed to add an ALTER TABLE tableName ALTER SORTKEY AUTO statementwhen the sort key "changed" to AUTO. [1] Since previously the property wasundefined`, the property is detected as changed and the ALTER statement is attempted to be executed but will fail because Redshift has defaulted to create the table with SORTKEY AUTO.

[1] https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-redshift-alpha/lib/private/database-query-provider/table.ts?t=7#L177-L194

Expected Behavior

Handler should not fail in this scenario.

Current Behavior

Handler fails, resource rolls back.

Reproduction Steps

n/a

Possible Solution

Probably one of these three:

  • Improve the condition for when to add the ALTER TABLE tableName SORTKEY AUTO statement to not be added when sortKey prop was previously undefined
  • Catch the error for the above ALTER statement and don't fail the handler if the error is because the table already is in the desired state
  • Change the handler to check the actual state of the table to decide which ALTER statements need to be executed.

Additional Information/Context

n/a

CDK CLI Version

2.88.0

Framework Version

2.88.0

Node.js Version

18

OS

MacOs

Language

Typescript

Language Version

No response

Other information

No response

@mrgrain mrgrain added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 21, 2023
@github-actions github-actions bot added the @aws-cdk/aws-redshift Related to Amazon Redshift label Jul 21, 2023
@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jul 21, 2023
@pahud pahud added p2 and removed p1 labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-redshift Related to Amazon Redshift bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants