Skip to content

Retry moving mountpoint sane amount of times#37956

Merged
VicDeo merged 3 commits intomasterfrom
bugfix/e4094
Nov 9, 2020
Merged

Retry moving mountpoint sane amount of times#37956
VicDeo merged 3 commits intomasterfrom
bugfix/e4094

Conversation

@VicDeo
Copy link
Member

@VicDeo VicDeo commented Sep 28, 2020

Description

  • Catch and handle integrity constraint violations and return false as expected
  • Make 10 attempts to move the mountpoint

Related Issue

Motivation and Context

a newly generated mounpoint path may exist but hasn't been mount yet. An attempt to move to this path will cause breaking constraint on index sh_external_mp for oc_share_external table

How Has This Been Tested?

no exact reproduction steps provided 🙅

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:
  • Changelog item, see TEMPLATE

@VicDeo VicDeo added this to the development milestone Sep 28, 2020
@VicDeo VicDeo self-assigned this Sep 28, 2020
@update-docs
Copy link

update-docs bot commented Sep 28, 2020

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@codecov
Copy link

codecov bot commented Sep 28, 2020

Codecov Report

Merging #37956 into master will decrease coverage by 0.50%.
The diff coverage is 58.82%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #37956      +/-   ##
============================================
- Coverage     65.22%   64.71%   -0.51%     
- Complexity    19445    19448       +3     
============================================
  Files          1286     1286              
  Lines         76031    76043      +12     
  Branches       1336     1336              
============================================
- Hits          49590    49215     -375     
+ Misses        26441    26434       -7     
- Partials          0      394     +394     
Flag Coverage Δ Complexity Δ
javascript 54.06% <ø> (-5.23%) 0.00 <ø> (ø)
phpunit 65.89% <58.82%> (+0.01%) 19448.00 <0.00> (+3.00)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
apps/files_sharing/lib/External/Manager.php 89.01% <0.00%> (-1.05%) 34.00 <0.00> (+1.00) ⬇️
apps/files_sharing/lib/External/Mount.php 25.00% <0.00%> (-2.28%) 5.00 <0.00> (+1.00) ⬇️
...b/private/Files/Config/MountProviderCollection.php 91.22% <83.33%> (-1.37%) 19.00 <0.00> (+1.00) ⬇️
core/js/oc-backbone.js 50.00% <0.00%> (-50.00%) 0.00% <0.00%> (ø%)
apps/comments/js/app.js 66.66% <0.00%> (-33.34%) 0.00% <0.00%> (ø%)
core/js/oc-requesttoken.js 75.00% <0.00%> (-25.00%) 0.00% <0.00%> (ø%)
core/js/systemtags/systemtagsmappingcollection.js 47.36% <0.00%> (-21.06%) 0.00% <0.00%> (ø%)
core/js/systemtags/systemtagmodel.js 72.72% <0.00%> (-18.19%) 0.00% <0.00%> (ø%)
core/js/sharescollection.js 42.85% <0.00%> (-14.29%) 0.00% <0.00%> (ø%)
apps/comments/js/commentcollection.js 72.72% <0.00%> (-13.64%) 0.00% <0.00%> (ø%)
... and 56 more

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 379847c...69b9b85. Read the comment docs.

@VicDeo VicDeo changed the title Catch constraint violations on external mount updates Retry moving mountpoint sane amount of times Oct 1, 2020
@micbar micbar requested a review from jvillafanez October 19, 2020 08:29
@jvillafanez
Copy link
Member

Is it possible to get the list of the mount points from the DB somehow? Otherwise, I agree we should make the amount of times configurable.

@VicDeo
Copy link
Member Author

VicDeo commented Oct 19, 2020

@jvillafanez we know nothing about DB in the context of lib/private/Files/Config/MountProviderCollection.php
what we have in MountProviderCollection::getMountsForUser is an array of providers.

@phil-davis
Copy link
Contributor

https://drone.owncloud.com/owncloud/core/27320/139/15

--- Failed scenarios:

    /drone/src/tests/acceptance/features/webUISharingInternalGroups1/shareWithGroups.feature:133
    /drone/src/tests/acceptance/features/webUISharingInternalGroups1/shareWithGroups.feature:150
    /drone/src/tests/acceptance/features/webUISharingInternalGroups1/shareWithGroups.feature:170
    /drone/src/tests/acceptance/features/webUISharingInternalGroups1/shareWithGroups.feature:183

32 scenarios (28 passed, 4 failed)
471 steps (458 passed, 4 failed, 9 skipped)

This sort of problem was reported:

    Then a notification should be displayed on the webUI with the text "Email notification was sent!"              # WebUIGeneralContext::aNotificationShouldBeDisplayedOnTheWebUIWithTheText()
      WebUIGeneralContext::aNotificationShouldBeDisplayedOnTheWebUIWithTheText A notification was expected to be displayed on the webUI with the text 'Email notification was sent!', but got '' instead
      Failed asserting that two strings are equal.
      --- Expected
      +++ Actual
      @@ @@
      -'Email notification was sent!'
      +''

I don't see how the code in this PR could break that. I will restart drone...

@phil-davis
Copy link
Contributor

And this time it passed.

@micbar
Copy link
Contributor

micbar commented Oct 26, 2020

@VicDeo Can we make the amount of retries configurable?

@mmattel
Copy link
Contributor

mmattel commented Oct 31, 2020

This is docs relevant (config-to-docs run) because of a change in config/config.sample.php.
I propose to give the description in config/config.sample.php a bit more text for better understanding what it is about.

@VicDeo
Copy link
Member Author

VicDeo commented Nov 2, 2020

@mmattel frankly speaking I just made it configurable as requested. The only explanation I can add: "if you don't know what is it about then you most likely have no need to adjust it"

@mmattel
Copy link
Contributor

mmattel commented Nov 2, 2020

if you don't know what is it about then you most likely have no need to adjust it

I completely agree. In case it gets merged, 3 months later, nobody will remember what it was about. Means, you do not only add a improved description for endusers, but also for ownCloud itself to prevent that.

@VicDeo
Copy link
Member Author

VicDeo commented Nov 2, 2020

@mmattel I don't know how to explain it properly

0 There could be a collision of the l mount point name for local and remote shares. E.g. when both are named file

  1. In this case we move the mount point using the following rule - file (1), file (2), etc. The name is generated by checking whether file (n) exists on the file system.
  2. if the storage goes offline for the remote share it could happen that file (n) does NOT exist on the file system but it's still not possible to move the mount point as we already have file (n) in the database but it is not mounted to filesystem . So the move operation returns false
  3. When we have false after the move operation we consider file (n) name is unavailable regardless the fact it does NOT exist on the file system and retry the move operation with file (n+1).
  4. 3 is repeated exactly filesystem.max_mountpoint_move_attempts times to avoid an infinite loop.

@mmattel
Copy link
Contributor

mmattel commented Nov 2, 2020

What about:
This config value avoids infinite loops for seldom cases where a file renaming conflict could occur.
The value defines how many unsuccessful rename attempts are allowed, if the mountpoint to a file is taken but the initiated rename failed. Change this value only under supervision of ownCloud support.

Pls check the text if valid and consistent and adopt if needed.

@VicDeo
Copy link
Member Author

VicDeo commented Nov 2, 2020

@mmattel what about

/**
 * This config value avoids infinite loops for seldom cases where a file renaming
 * conflict between different share backends could occur.
 * The value defines how many unsuccessful mountpoint rename attempts are allowed.
 * E.g. target mountpoint name could be claimed as unused by the filesystem but
 * renaming to this target name will fail due to some other reasons like database 
 * constraints.
 * Change this value only under supervision of ownCloud support.
 */

Is it clear enough?

@mmattel
Copy link
Contributor

mmattel commented Nov 2, 2020

This is great 👍
One thing I would do: even when starting at the beginning of the sentence, I would write E.g.-->e.g.
Else it looks at least to my eyes awful 😄

@phil-davis
Copy link
Contributor

phil-davis commented Nov 4, 2020

I don't see a changelog entry yet?

And needs a rebase due to the composer 2.0 changes 2 days ago.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me now.
@jvillafanez review?

@VicDeo VicDeo merged commit 89b08ad into master Nov 9, 2020
@delete-merged-branch delete-merged-branch bot deleted the bugfix/e4094 branch November 9, 2020 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants