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

[stable10] Protect group share concurrent updates with upsert #34769

Merged
merged 1 commit into from Apr 5, 2019

Conversation

PVince81
Copy link
Contributor

Description

To avoid race conditions happening exactly between the select and
insert/update.

Related Issue

https://github.com/owncloud/enterprise/issues/3167 and #27990

Motivation and Context

How Has This Been Tested?

Automated tests

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 15, 2019

  • check upsert

@codecov
Copy link

codecov bot commented Mar 15, 2019

Codecov Report

Merging #34769 into stable10 will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff               @@
##             stable10   #34769      +/-   ##
==============================================
+ Coverage       64.19%    64.2%   +<.01%     
  Complexity      19883    19883              
==============================================
  Files            1278     1278              
  Lines           76244    76246       +2     
  Branches         1291     1291              
==============================================
+ Hits            48948    48950       +2     
  Misses          26917    26917              
  Partials          379      379
Flag Coverage Δ Complexity Δ
#javascript 53.22% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 65.36% <100%> (ø) 19883 <0> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
lib/private/Share20/DefaultShareProvider.php 98.33% <100%> (ø) 114 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04843c7...32d622f. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Mar 15, 2019

Codecov Report

Merging #34769 into stable10 will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff               @@
##             stable10   #34769      +/-   ##
==============================================
+ Coverage       64.19%    64.2%   +<.01%     
  Complexity      19883    19883              
==============================================
  Files            1278     1278              
  Lines           76244    76246       +2     
  Branches         1291     1291              
==============================================
+ Hits            48948    48950       +2     
  Misses          26917    26917              
  Partials          379      379
Flag Coverage Δ Complexity Δ
#javascript 53.22% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 65.36% <100%> (ø) 19883 <0> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
lib/private/Share20/DefaultShareProvider.php 98.33% <100%> (ø) 114 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04843c7...32d622f. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 15, 2019

Codecov Report

Merging #34769 into stable10 will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff               @@
##             stable10   #34769      +/-   ##
==============================================
- Coverage       64.25%   64.24%   -0.01%     
- Complexity      19990    19993       +3     
==============================================
  Files            1281     1281              
  Lines           76663    76648      -15     
  Branches         1307     1307              
==============================================
- Hits            49258    49243      -15     
  Misses          27024    27024              
  Partials          381      381
Flag Coverage Δ Complexity Δ
#javascript 53.01% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 65.44% <100%> (-0.01%) 19993 <0> (+3)
Impacted Files Coverage Δ Complexity Δ
lib/private/Share20/DefaultShareProvider.php 98.37% <100%> (-0.06%) 120 <0> (-1)
apps/dav/lib/Connector/Sabre/FilesPlugin.php 87.07% <0%> (-0.72%) 77% <0%> (+4%)
lib/private/Server.php 86.65% <0%> (+0.11%) 253% <0%> (ø) ⬇️
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php 81.81% <0%> (+0.42%) 14% <0%> (ø) ⬇️
apps/files_trashbin/lib/Expiration.php 98.27% <0%> (+1.72%) 29% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5ed97c...ee04539. Read the comment docs.

@PVince81
Copy link
Contributor Author

  • alternatives to look into: using upsert (requires deprecation of sqlite and making sure that all DBs are supported)
  • analyze potential impact on cluster systems

@PVince81
Copy link
Contributor Author

  • explore the possibility of adding a DB constraint to avoid duplicates

note that even if we only add a constraint without this fix, there is some probability of random error messages

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 20, 2019

after discussing with @tomneedham

transactions not a good idea as they could cause deadlocks

  • let's try with upsert()
  • make sure this properly covered with integration tests

@PVince81 PVince81 force-pushed the stable10-transaction-for-subshares branch from 32d622f to 29d53be Compare March 25, 2019 14:55
@PVince81
Copy link
Contributor Author

Upsert added and this is already covered by unit tests and seem to work.

Let's see if it also works in a broader scope (integration/acceptance tests in CI).

@PVince81
Copy link
Contributor Author

also had a quick test in the UI with a group share and renamed / unshared from self as recipient to test insert and update. the DB entries were updated fine.

@PVince81 PVince81 changed the title [stable10] Protect group share updates with transaction [stable10] Protect group share concurrent updates with upsert Mar 26, 2019
@PVince81
Copy link
Contributor Author

PVince81 commented Apr 1, 2019

@tomneedham review upsert ?

@PVince81
Copy link
Contributor Author

PVince81 commented Apr 2, 2019

master port here: #34952

To avoid race conditions happening exactly between the select and
insert/update.
@PVince81 PVince81 force-pushed the stable10-transaction-for-subshares branch from 29d53be to ee04539 Compare April 5, 2019 09:21
@PVince81
Copy link
Contributor Author

PVince81 commented Apr 5, 2019

adjusted to solve conflict, now that #34951 was merged

@PVince81 PVince81 merged commit bbab040 into stable10 Apr 5, 2019
@delete-merged-branch delete-merged-branch bot deleted the stable10-transaction-for-subshares branch April 5, 2019 11:28
@PVince81 PVince81 modified the milestones: development, QA Apr 12, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants