Skip to content

upgrade to sharing 2.0, remove hierarchical re-shares - #21660

Merged
DeepDiver1975 merged 3 commits into
masterfrom
sharing2_update_reshares
Jan 29, 2016
Merged

DeepDiver1975 merged 3 commits into
masterfrom
sharing2_update_reshares

Conversation

@schiessle

Copy link
Copy Markdown
Contributor

Update script to remove all hierarchical re-shares and create a flat list instead.

I will add unit test over the next days... Feel free to have a look if you see stuff which could be optimized/improved.

cc @rullzer @DeepDiver1975

@schiessle schiessle added this to the 9.0-current milestone Jan 12, 2016
@mention-bot

Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified @rullzer, @icewind1991 and @MTRichards to be potential reviewers

@rullzer

rullzer commented Jan 12, 2016

Copy link
Copy Markdown
Contributor

Great start!

@rullzer rullzer mentioned this pull request Jan 12, 2016
35 of 43 tasks
Comment thread apps/files_sharing/lib/migration.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use in() ??? - just an idea - no clue if that could help with query execution ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm also not sure if there is a performance difference... still it makes probably sense to use the in operator here

@schiessle

Copy link
Copy Markdown
Contributor Author

While writing tests I wonder if we also want to move the password for link shares from the "share_with" column to a new column "password"? I always hated that we abuse the share_with column for the password. I think now it would be the right time to change it... What do you think @DeepDiver1975 @rullzer ?

@rullzer

rullzer commented Jan 13, 2016

Copy link
Copy Markdown
Contributor

@schiesbn We can only do that once we have moved all the internal handling to that column as well... so basically after all is done we can move it.. but now there are still to many places that use the old code path...

@rullzer

rullzer commented Jan 13, 2016

Copy link
Copy Markdown
Contributor

@schiesbn but i agree it has to go :P

@schiessle

Copy link
Copy Markdown
Contributor Author

We can only do that once we have moved all the internal handling to that column as well... so basically after all is done we can move it.. but now there are still to many places that use the old code path...

OK, so let's do this in a second step.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

ci error:

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to OCA\Files_Sharing\Migration::__construct() must implement interface OCP\IDBConnection, none given, called in /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/apps/files_sharing/tests/migrationtest.php on line 63 and defined in /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/apps/files_sharing/lib/migration.php:37
11:03:46 Stack trace:
11:03:46 #0 /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/apps/files_sharing/tests/migrationtest.php(63): OCA\Files_Sharing\Migration->__construct()
11:03:46 #1 [internal function]: MigrationTest->testAddAccept()
11:03:46 #2 phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php(865): ReflectionMethod->invokeArgs(Object(MigrationTest), Array)
11:03:46 #3 phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php(743): PHPUnit_Framework_TestCase->runTest()
11:03:46 #4 phar:///usr/local/bin/phpunit/php-invoker/Invoker.php(93): PHPUnit_Framework_TestCase->runBare()
11:03:46 #5 phar:///usr/local/bin/phpu in /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/apps/files_sharing/lib/migration.php on line 37

@schiessle

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 this are still the tests for the old migration class... Ignore it for now. Updated unit tests will come soon 😄

Comment thread apps/files_sharing/lib/migration.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens on commit failure? 🙈 Is it still consistent and can be called a second time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, if the commit fails nothing was changed and you can call it a second time.

This was exactly the reason why I used a transaction here (beside some potential performance improvements), I want to make sure that either we update all shares or none so that it can be safely re-run in case of a error.

@schiessle
schiessle force-pushed the sharing2_update_reshares branch 3 times, most recently from f7b732e to 2b4ac5a Compare January 13, 2016 14:11
@DeepDiver1975

Copy link
Copy Markdown
Contributor

pgsql issue:

MigrationTest::testRemoveReShares
Doctrine\DBAL\Exception\SyntaxErrorException: An exception occurred while executing 'UPDATE "oc_share" SET "parent" = ?, "uid_owner" = ?, "uid_initiator" = ?, "parent" = ?, "uid_owner" = ?, "uid_initiator" = ? WHERE "id" = ?' with params [null, "owner2", "user1", null, "owner2", "user2", 346]:

SQLSTATE[42601]: Syntax error: 7 ERROR:  multiple assignments to same column "parent"

/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php:66
/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:116
/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:996
/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/lib/private/db/connection.php:203
/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php:208
/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/lib/private/db/querybuilder/querybuilder.php:124
/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/apps/files_sharing/lib/migration.php:156
/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/apps/files_sharing/lib/migration.php:57
/ssd/jenkins/workspace/core-ci-linux@6/database/pgsql/label/SLAVE/apps/files_sharing/tests/migrationtest.php:215

@DeepDiver1975

Copy link
Copy Markdown
Contributor

oracel issue:

MigrationTest::testRemoveReShares
Doctrine\DBAL\Driver\OCI8\OCI8Exception: ORA-02289: sequence does not exist

/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php:33
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php:214
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php:116
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php:157
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:1087
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/lib/private/db/connection.php:226
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/lib/private/db/adapteroci8.php:36
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/lib/private/db/connection.php:221
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/apps/files_sharing/tests/migrationtest.php:144
/ssd/jenkins/workspace/core-ci-linux@2/database/oci/label/SLAVE/apps/files_sharing/tests/migrationtest.php:214

@schiessle
schiessle force-pushed the sharing2_update_reshares branch from 2b4ac5a to 071e443 Compare January 13, 2016 16:54
@schiessle

Copy link
Copy Markdown
Contributor Author

I fixed the pgsql error, but I have no idea oci doesn't like $parent = $this->connection->lastInsertId($this->table); https://github.com/owncloud/core/pull/21660/files#diff-9617a0875321cd12aaccd88a631e5dadR144 @DeepDiver1975 any idea?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

aaah you forgot the backticks!

@schiessle
schiessle force-pushed the sharing2_update_reshares branch 2 times, most recently from 0a40d5d to 3666b32 Compare January 14, 2016 13:44
@schiessle

Copy link
Copy Markdown
Contributor Author

now it should work... let's cross the fingers 😉

@schiessle
schiessle force-pushed the sharing2_update_reshares branch from 3666b32 to 4db4346 Compare January 14, 2016 15:14
@schiessle

Copy link
Copy Markdown
Contributor Author

perfect... all tests passed. Failing tests are unrelated (cURL error 7: Failed to connect to localhost port 8083: Connection refused)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing you can fix here. But it is kinda weird this needs to be included here. Breaks the abstraction

@rullzer
rullzer force-pushed the sharing2_update_reshares branch 3 times, most recently from 05e4d89 to 3c671fa Compare January 25, 2016 18:42
@rullzer

rullzer commented Jan 25, 2016

Copy link
Copy Markdown
Contributor

Ok updated this PR.

  • Queries are now done in chunks of 1000 shares
  • Cache caches max 10k shares (~20MB).
  • Also migrate non reshares to new format (owner/initiator).

Everything still passes.

@rullzer

rullzer commented Jan 25, 2016

Copy link
Copy Markdown
Contributor

I tested locally and for me migrating approx 100k shares takes 2 minutes and 40 seconds. This is including ~500K assertions. Wich seems very reasonable.

@rullzer

rullzer commented Jan 25, 2016

Copy link
Copy Markdown
Contributor

@schiesbn @nickvergessen @DeepDiver1975 @PVince81 @LukasReschke please review.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

This requires heavy upgrade testing by @owncloud/qa

@DeepDiver1975

Copy link
Copy Markdown
Contributor

owncloud/QA#92

@rullzer

rullzer commented Jan 26, 2016

Copy link
Copy Markdown
Contributor

@DeepDiver1975 yes it does!

owncloud/QA#92

Thanks

@rullzer

rullzer commented Jan 28, 2016

Copy link
Copy Markdown
Contributor

Now that the webUI uses the OCS Share API as well. It is time to get this in! So everybody just uses new shares!

CC: @DeepDiver1975 @PVince81 @MorrisJobke @nickvergessen

@PVince81

Copy link
Copy Markdown
Contributor

Had a quick test, set up some reshares on master stable8.2 and also some reshares from inside subfolders as recipient. Ran the upgrade. The shares were flatten properly, looks nice!

@PVince81

Copy link
Copy Markdown
Contributor

Okay, I tested again this time starting on stable8.2, because master isn't suitable for testing because it already creates the shares in the correct format, not legacy.
Worked with link shares, reshares, different files_targets, double shares (shared to same zser through user + group), fed shares, reshared fed shares, reshared subdirs.

@PVince81

Copy link
Copy Markdown
Contributor

Code looks good too 👍

@PVince81

Copy link
Copy Markdown
Contributor

Needs a seconds reviewer @nickvergessen @MorrisJobke @icewind1991

@rullzer
rullzer force-pushed the sharing2_update_reshares branch from 3c671fa to 6151a05 Compare January 28, 2016 18:27
@MorrisJobke

Copy link
Copy Markdown
Contributor

Tested and works 👍

DeepDiver1975 added a commit that referenced this pull request Jan 29, 2016
upgrade to sharing 2.0, remove hierarchical re-shares
@DeepDiver1975
DeepDiver1975 merged commit 8ad45da into master Jan 29, 2016
@DeepDiver1975
DeepDiver1975 deleted the sharing2_update_reshares branch January 29, 2016 13:43
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 8, 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.

6 participants