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
Lock/unlock tables when editing entries #2585
Conversation
When editing an entry, Symphony will iterate over all fields, delete existing data first, then insert a new row for the field's data. So there will always be a time slot without field data. If multiple processes edit the same entry, this means a race condition that may lead to data being corrupted in several ways (also depending on the field type). Locking the table solves the issue. Fixes symphonycms#2472
} | ||
|
||
Symphony::Database()->insert($fields, 'tbl_entries_data_' . $field_id); | ||
if ($did_lock) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block should be in a finally statement to be 100% kasher (if I am not wrong?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed that some months ago (#2472 (comment)); the issue is that finally
requires PHP 5.5+.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always forget about that. Thanks!
Thanks Michael. See my comments! |
I merge ASAP then! |
58bc57f added DISTINCT and LIMIT clauses to sub-queries used for sorts. The sub-query MUST return only one row, and (sometimes) it does not. See <INSERT REF HERE> As demonstrated by @michael-e, doing this does not suffice, since the php code also needs to change (or we would need to add more DISTINCT which is not better). The new table locking mechanism (symphonycms#2585) + making sure we update existing sites that are missing the unique key should prevent (hopefully) any data corroption before it can happen.
When editing an entry, Symphony will iterate over all fields, delete existing data first, then insert a new row for the field's data. So there will always be a time slot without field data. If multiple processes edit the same entry, this means a race condition that may lead to data being corrupted in several ways (also depending on the field type). Locking the table solves the issue. Fixes #2472
58bc57f added DISTINCT and LIMIT clauses to sub-queries used for sorts. The sub-query MUST return only one row, and (sometimes) it does not. See <INSERT REF HERE> As demonstrated by @michael-e, doing this does not suffice, since the php code also needs to change (or we would need to add more DISTINCT which is not better). The new table locking mechanism (#2585) + making sure we update existing sites that are missing the unique key should prevent (hopefully) any data corroption before it can happen.
When editing an entry, Symphony will iterate over all fields, delete existing data first, then insert a new row for the field's data. So there will always be a time slot without field data. If multiple processes edit the same entry, this means a race condition that may lead to data being corrupted in several ways (also depending on the field type). Locking the table solves the issue. Fixes #2472 Picked from 4b5067f
58bc57f added DISTINCT and LIMIT clauses to sub-queries used for sorts. The sub-query MUST return only one row, and (sometimes) it does not. See <INSERT REF HERE> As demonstrated by @michael-e, doing this does not suffice, since the php code also needs to change (or we would need to add more DISTINCT which is not better). The new table locking mechanism (#2585) + making sure we update existing sites that are missing the unique key should prevent (hopefully) any data corroption before it can happen. Picked from 86717ba
When editing an entry, Symphony will iterate over all fields, delete existing data first, then insert a new row for the field's data. So there will always be a time slot without field data. If multiple processes edit the same entry, this means a race condition that may lead to data being corrupted in several ways (also depending on the field type). Locking the table solves the issue. Fixes #2472 Picked from 4b5067f
58bc57f added DISTINCT and LIMIT clauses to sub-queries used for sorts. The sub-query MUST return only one row, and (sometimes) it does not. See <INSERT REF HERE> As demonstrated by @michael-e, doing this does not suffice, since the php code also needs to change (or we would need to add more DISTINCT which is not better). The new table locking mechanism (#2585) + making sure we update existing sites that are missing the unique key should prevent (hopefully) any data corroption before it can happen. Picked from 86717ba
When editing an entry, Symphony will iterate over all fields, delete existing data first, then insert a new row for the field's data. So there will always be a time slot without field data. If multiple processes edit the same entry, this means a race condition that may lead to data being corrupted in several ways (also depending on the field type). Locking the table solves the issue.
Fixes #2472