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

Fix UniqueConstraintViolationException while insert into oc_filecache #12411

Merged
merged 1 commit into from
Nov 12, 2018

Conversation

MorrisJobke
Copy link
Member

I would back port this one to stable13 and stable14 as well because it is a smaller and not that invasive version of #12371 and it also fixes the deadlocks.

* fixes #6160 by not being prone to the race condition in insertIfNotExists
* fixes #12228 by not using a query that can result in a deadlock
* replaces the insertIfNotExists call with an insert which is wrapped into a try-catch block

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
@MorrisJobke MorrisJobke force-pushed the bugfix/6160/oc_filecache-unique-constraint branch from 89ba561 to 93c62d7 Compare November 12, 2018 13:43
$builder->insert('filecache');

foreach ($values as $column => $value) {
$builder->setValue($column, $builder->createNamedParameter($value));
Copy link
Member Author

Choose a reason for hiding this comment

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

It also said, that there is an sql injection problem (this came from our plugin to Phan). I double checked and the column as well as the argument are both properly escaped.

@kesselb
Copy link
Contributor

kesselb commented Nov 12, 2018

INSERT INTO `oc_filecache` (`mimepart`,
                            `mimetype`,
                            `mtime`,
                            `size`,
                            `etag`,
                            `storage_mtime`,
                            `permissions`,
                            `parent`,
                            `checksum`,
                            `path_hash`,
                            `path`,
                            `name`,
                            `storage`)
VALUES ('11',
        '14',
        1542033752,
        544134,
        'b81868bb19bc3b3769e1954d2e387359',
        1542033752,
        27,
        2,
        '',
        '9a341df1023c4809dddef853beb3d4ee',
        'files/dummy-1440x960-Stones.jpg',
        'dummy-1440x960-Stones.jpg',
        1);

Query looks good and unique constraint is working. mimepart and mimetype passed as string and stored as bigint but insertIfNotExist works similiar 👍

@MorrisJobke
Copy link
Member Author


Query looks good and unique constraint is working. mimepart and mimetype passed as string and stored as bigint but insertIfNotExist works similiar 👍

Yep - I didn't changed anything there. We can tackle the types later, but for now I want to go for the least intrusive way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
4 participants