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

Adding repair step for sub share #30186

Merged
merged 1 commit into from
Feb 23, 2018
Merged

Adding repair step for sub share #30186

merged 1 commit into from
Feb 23, 2018

Conversation

sharidas
Copy link
Contributor

Adding repair step for sub share.
When share table due to some magic gets
duplicate entries for sub share ( except the id or primary
key ), then this repair step comes for rescue.

Signed-off-by: Sujith H sharidasan@owncloud.com

Description

Remove the duplicate entries from the share table which can cause exception described in the issue.

Related Issue

#27990

Motivation and Context

For some magical reason, if the share table gets populated with duplicate entries then we would have to remove the duplicate entry. Keeping the row with minimum id. Else exception would be thrown as mentioned in the issue.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@sharidas sharidas added this to the development milestone Jan 18, 2018
@sharidas sharidas self-assigned this Jan 18, 2018
@sharidas
Copy link
Contributor Author

Need to write unit test. But so far with the scenario mentioned in the issue, when I run the maintenance:repair command the output is as follows:

sujith@sujith-Inspiron-5567 ~/test/owncloud2 $ ./occ maintenance:repair 
Cannot load Xdebug - it was already loaded
ownCloud is in maintenance mode - no app have been loaded

 - Repair mime types
 - Detect file cache entries with path that does not match parent-child relationships
 - Generate ETags for file where no ETag is present.
     - ETags have been fixed for 0 files/folders.
 - Clean tags and favorites
     - 0 tags of deleted users have been removed.
     - 0 tags for delete files have been removed.
     - 0 tag entries for deleted tags have been removed.
     - 0 tags with no entries have been removed.
 - Drop old database tables
 28/28 [============================] 100%
 - Drop old background jobs
 - Remove getetag entries in properties table
     - Removed 0 unneeded "{DAV:}getetag" entries from properties table.
 - Repair outdated OCS IDs
 - Repair invalid shares
 - Remove old share propagation app entries
 - Move user avatars outside the homes to the new location
 - Remove shares of a users root folder
 - Repair unmerged shares
 - Disable extra themes
 - Repair sub shares
     - Removed 1 shares where duplicate rows where found
sujith@sujith-Inspiron-5567 ~/test/owncloud2 $ ./occ maintenance:repair 
Cannot load Xdebug - it was already loaded
ownCloud is in maintenance mode - no app have been loaded

 - Repair mime types
 - Detect file cache entries with path that does not match parent-child relationships
 - Generate ETags for file where no ETag is present.
     - ETags have been fixed for 0 files/folders.
 - Clean tags and favorites
     - 0 tags of deleted users have been removed.
     - 0 tags for delete files have been removed.
     - 0 tag entries for deleted tags have been removed.
     - 0 tags with no entries have been removed.
 - Drop old database tables
 28/28 [============================] 100%
 - Drop old background jobs
 - Remove getetag entries in properties table
     - Removed 0 unneeded "{DAV:}getetag" entries from properties table.
 - Repair outdated OCS IDs
 - Repair invalid shares
 - Remove old share propagation app entries
 - Move user avatars outside the homes to the new location
 - Remove shares of a users root folder
 - Repair unmerged shares
 - Disable extra themes
 - Repair sub shares
sujith@sujith-Inspiron-5567 ~/test/owncloud2 $

@codecov
Copy link

codecov bot commented Jan 18, 2018

Codecov Report

Merging #30186 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #30186      +/-   ##
============================================
+ Coverage     58.36%   58.36%   +<.01%     
- Complexity    18566    18573       +7     
============================================
  Files          1093     1094       +1     
  Lines         63771    63805      +34     
============================================
+ Hits          37217    37242      +25     
- Misses        26554    26563       +9
Impacted Files Coverage Δ Complexity Δ
drone/src/lib/private/Group/Database.php 98.36% <0%> (-1.64%) 24% <0%> (ø)
drone/src/lib/private/Repair.php 27.16% <0%> (-0.69%) 21% <0%> (ø)
drone/src/lib/private/Repair/RepairSubShares.php 81.25% <0%> (ø) 7% <0%> (?)
drone/src/lib/private/Server.php 82.69% <0%> (+0.14%) 129% <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 e1c4425...2f09bd8. Read the comment docs.

@sharidas
Copy link
Contributor Author

Created the tests for this repair PR.


public function run(IOutput $output) {
$deletedEntries = 0;
$this->removeRowsWithDuplicateDataExceptId();
Copy link
Contributor

Choose a reason for hiding this comment

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

this function's name is lying. It is not removing rows with duplicate data except id. It's only setting some attributes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PVince81 Yes its making the query statement with attributes. Will get it corrected. It was there in my mind sometime back and then got slipped :( Thanks.

@sharidas sharidas force-pushed the repair-step-subshare branch 3 times, most recently from a689afc to 8d67c73 Compare January 21, 2018 06:30
@sharidas sharidas changed the title [WIP] Adding repair step for sub share [Adding repair step for sub share Jan 22, 2018
@sharidas sharidas changed the title [Adding repair step for sub share Adding repair step for sub share Jan 22, 2018
Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

Looks fine, see comment

'share_with' => $qb->expr()->literal($userName.$groupCount),
'uid_owner' => $qb->expr()->literal('admin'),
'uid_initiator' => $qb->expr()->literal('admin'),
'parent' => $qb->expr()->literal(1),
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest you also vary the parent value considering that we use it on the group by

])
->execute();

if (($i%3) === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

a bit more fresh air appreciated

Adding repair step for sub share.
When share table due to some magic gets
duplicate entries ( except the id or primary
key ), then this repair step comes for rescue.

Signed-off-by: Sujith H <sharidasan@owncloud.com>
@PVince81
Copy link
Contributor

PVince81 commented Feb 7, 2018

any update ?

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

@PVince81 PVince81 merged commit 48ef206 into master Feb 23, 2018
@PVince81 PVince81 deleted the repair-step-subshare branch February 23, 2018 14:18
@PVince81
Copy link
Contributor

@sharidas please backport

@sharidas
Copy link
Contributor Author

sharidas commented Mar 5, 2018

Backport PR: #30695

@phil-davis
Copy link
Contributor

Backport PR has been done and merged.

@PVince81 PVince81 mentioned this pull request Apr 3, 2018
9 tasks
@lock
Copy link

lock bot commented Jul 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
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.

4 participants