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

Ignore duplicate inserts in file cache and mime type #5442

Merged
merged 1 commit into from
Oct 23, 2013

Conversation

PVince81
Copy link
Contributor

Catch duplicate insertion errors while scanning files

When two scanning processed run at the same time, for example when
scan.php and list.php were called at the same time on an external
storage mountpoint, duplicate insertion errors can occurs.

These errors are now logged and ignored.

Since both scans are running in parallel transactions, they don't see
each other's changes directly in the DB which can cause duplicate
insertion errors for mime types as well, but those mime types can't be
selected yet. The solution to this is to force-reload the mimetypes list
after the transaction is finished.

Fixes #5199

catch (\Doctrine\DBAL\DBALException $e){
\OC_Log::write('core', 'Exception during file cache insertion: ' . $e->getmessage(), \OC_Log::DEBUG);
// in case of duplicate insert error, retrieve the existing file data
$fileId = self::getId($file);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason getId() returns -1, as the select inside doesn't return any results for some mysterious reason.

@ghost
Copy link

ghost commented Oct 21, 2013

Test passed.
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/1657/

catch (\Doctrine\DBAL\DBALException $e){
\OC_Log::write('core', 'Exception during mimetype insertion: ' . $e->getmessage(), \OC_Log::DEBUG);
// in case of duplicate insert error, retrieve the existing mime type id
$result = \OC_DB::executeAudited('SELECT `id` FROM `*PREFIX*mimetypes` WHERE mimetype=?', array($mime));
Copy link
Member

Choose a reason for hiding this comment

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

should be mimetype - maybe this is why the query is not returning a proper result set?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I mean the backticks are missing on the where

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the issue with "no results" in the other block, the one wrapping the insert into oc_filecache, not the mimetype one.

When two scanning processed run at the same time, for example when
scan.php and list.php were called at the same time on an external
storage mountpoint, duplicate insertion errors can occurs.

These errors are now logged and ignored.

Since both scans are running in parallel transactions, they don't see
each other's changes directly in the DB which can cause duplicate
insertion errors for mime types as well, but those mime types can't be
selected yet. The solution to this is to force-reload the mimetypes list
after the transaction is finished.

Fixes #5199
@PVince81
Copy link
Contributor Author

I've updated the PR description that explains the current approach.

Please review this approach: @karlitschek @icewind1991 @DeepDiver1975 @bantu

@ghost
Copy link

ghost commented Oct 23, 2013

Test passed.
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/1730/

@ghost
Copy link

ghost commented Oct 23, 2013

Test passed.
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/1732/

@karlitschek
Copy link
Contributor

👍

@jancborchardt
Copy link
Member

THIS FINALLY FIXED #5372 for me! I love you @PVince81! :)

I don’t want to thumbs up it though because I can’t judge over the code. Just saying it fixed a really annoying issue for me.

@PVince81
Copy link
Contributor Author

@jancborchardt glad to read that!

@ghost
Copy link

ghost commented Oct 23, 2013

Test passed.
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/1735/

@DeepDiver1975
Copy link
Member

👍

DeepDiver1975 added a commit that referenced this pull request Oct 23, 2013
Ignore duplicate inserts in file cache and mime type
@DeepDiver1975 DeepDiver1975 merged commit 3d5e229 into master Oct 23, 2013
@DeepDiver1975 DeepDiver1975 deleted the extstorage-ignoreduplicateinserts branch October 23, 2013 14:47
@lock lock bot locked as resolved and limited conversation to collaborators Aug 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate mimetype insertion during scan
5 participants