tink icon indicating copy to clipboard operation
tink copied to clipboard

rpc error: code = Unknown desc = COMMIT: pq: could not serialize access due to read/write dependencies among transactions

Open invidian opened this issue 5 years ago • 10 comments

Expected Behaviour

Tink server should be capable of handling requests in paralell.

Current Behaviour

Currently, when one applies multiple requests to tink server in parallel, server sometimes returns the following error:

Error: removing workflow "08b64643-010d-4ade-a43f-6ffa7f0afce8": rpc error: code = Unknown desc = COMMIT: pq: could not serialize access due to read/write dependencies among transactions

Steps to Reproduce (for bugs)

Currently, this is sometimes reproducible when using https://github.com/kinvolk/terraform-provider-tinkerbell and when running terraform destroy on large number of Tinkerbell resources.

Context

Your Environment

Tested using Tinkerbell sandbox with tinkerbell server from image quay.io/tinkerbell/tink:sha-adb49da.

invidian avatar Oct 10 '20 21:10 invidian

BTW, in some cases, like https://github.com/tinkerbell/tink/blob/34275668af5eede0475dae8f3aa6d75fe0cf0618/db/template.go#L17-L45, transaction is not even needed, as there is only a single query being made, which is already ensured to be atomic by the database itself, according to https://stackoverflow.com/a/1171807/2974814, unless I'm missing something.

invidian avatar Oct 12 '20 13:10 invidian

@kdeng3849 looks like what you're looking at right?

mmlb avatar Oct 13 '20 14:10 mmlb

@parauliya this is mitigation I talked about: https://github.com/kinvolk/terraform-provider-tinkerbell/commit/d4e4080646d51590944e4f656af2e85f67c85dd6.

invidian avatar Oct 13 '20 14:10 invidian

@mmlb yeah, that's exactly it

kqdeng avatar Oct 13 '20 14:10 kqdeng

@kdeng3849 what is the status of this?

thebsdbox avatar Dec 10 '20 11:12 thebsdbox

It has been fixed with this PR: https://github.com/tinkerbell/tink/pull/346

kqdeng avatar Dec 11 '20 16:12 kqdeng

Ah, BTW, this was also occurring for other resources, not only for workflows. I'll test if that's still the case.

invidian avatar Dec 15 '20 12:12 invidian

This still occurs when workflows are removed:

       Error: removing workflow "b06356a8-3ed4-11eb-a31e-0242ac1b0004": rpc error: code = Unknown desc = Delete Workflow Error: pq: could not serialize access due to read/write dependencies among transactions



        Error: removing workflow "b05ef9be-3ed4-11eb-a31e-0242ac1b0004": rpc error: code = Unknown desc = COMMIT: pq: could not serialize access due to read/write dependencies among transactions



        Error: removing workflow "b046f1ae-3ed4-11eb-a31e-0242ac1b0004": rpc error: code = Unknown desc = COMMIT: pq: could not serialize access due to read/write dependencies among transactions

Running Tinkerbell 266637ae. Can we please re-open?

invidian avatar Dec 15 '20 12:12 invidian

Creating/deleting Hardware entries and Templates seems OK.

invidian avatar Dec 15 '20 13:12 invidian

@invidian asked me to re-open, so I think it is not a fixed issue yet

gianarb avatar Dec 21 '20 13:12 gianarb

close by https://github.com/tinkerbell/tink/pull/654

jacobweinstock avatar Dec 23 '22 02:12 jacobweinstock