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

Serializable isolation violation on table X with Redshift using upsert #665

Closed
Falydoor opened this issue Apr 26, 2021 · 4 comments · Fixed by #667
Closed

Serializable isolation violation on table X with Redshift using upsert #665

Falydoor opened this issue Apr 26, 2021 · 4 comments · Fixed by #667
Assignees
Labels
bug Something isn't working minor release Will be addressed in the next minor release ready to release

Comments

@Falydoor
Copy link
Contributor

Describe the bug

I have a lambda that reads a file from S3 and then insert it to Redshift. I noticed that when multiple lambdas are inserting in the same table, the first one inserts things correctly but the others are raising the error below:

{'S': 'ERROR', 'C': 'XX000', 'M': '1023', 'D': 'Serializable isolation violation on table - 119371, transactions forming the cycle are: 1745830, 1745762 (pid:15021)', 'F': '/home/ec2-user/padb/src/sys/xen_execute.cpp', 'L': '9797', 'R': 'pg_throw'}

To Reproduce

Lambda layer 2.7.0 for Python 3.8

Code used to insert to RS (let me know if more informations are required):

con = wr.redshift.connect_temp(cluster_identifier=CLUSTERuser=USERdatabase='dev'auto_create=False)

wr.redshift.copy(df=DF,
path=S3_PATH,
con=con,
schema=SCHEMA,
table=TABLE,
mode='upsert',
iam_role=IAM_ROLE,
primary_keys=PKS)
@Falydoor Falydoor added the bug Something isn't working label Apr 26, 2021
@kukushking
Copy link
Contributor

Concurrent COPY commands break serial isolation.

I suggest to add a parameter to wrangler to be able to call LOCK before COPY. While this is being added, as a quick fix you could set up retries on your lambdas.

@jaidisido
Copy link
Contributor

Thank you @Falydoor for raising this and @kukushking for the quick fix. Now merged into main and can be tested via:

pip uninstall awswrangler -y
pip install git+https://github.com/awslabs/aws-data-wrangler.git@main

until it's available in the next release

@jaidisido jaidisido linked a pull request May 3, 2021 that will close this issue
@Falydoor
Copy link
Contributor Author

Falydoor commented May 4, 2021

Awesome! Thanks @kukushking @jaidisido

@jaidisido
Copy link
Contributor

Now covered in 2.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working minor release Will be addressed in the next minor release ready to release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants