Skip to content

File cache update() cannot set empty string on Oracle #31692

Closed

Description

@PVince81

Steps

  1. Set a checksum (maybe upload a file)
  2. Reset the checksum to empty string using the Node API: $file1->getStorage()->getCache()->update($file1->getId(), ['checksum' => '']);
  3. Check database

Expected result

Checksum cleared to empty string on all DBs.

Actual result

Checksum not cleared on Oracle, other DBs are fine.

Even more worrying is that if you set it to "null" in the update() function it doesn't work for all DBs.

Versions

OC 10.0.8

Discovered on #31430

Tech concept for the fix

  • add unit test for OC\File\Cache::update() to reproduce the issue and prove it's broken on Oracle
  • Modify OC\File\Cache to detect Oracle. If Oracle and the parameter to update is an empty string, convert it to NULL and adjust the query if necessary.
  • check if other parts of file cache might be affected
  • raise separate ticket for NULL issue

Please note that the update query contains a WHERE statement to avoid updating values that are already set to the same value in the DB. This needs special handling for nulls, etc.

At this point to avoid potential regressions for other DBs, I suggest ignoring the "setting NULL" issue and focus on Oracle only.

Estimate

  • Dev time including unit tests: 1-2md

@butonic @DeepDiver1975 @tomneedham

Activity

  1. added this to the backlog milestone on Jun 8, 2018
  2. added
    p3-medium
    on Jun 8, 2018
  3. PVince81 commented on Jun 8, 2018

    @PVince81
    ContributorAuthor

    This could potentially be critical because some code paths will clear values like the checksum, mostly in external storage update detection cases. If the value cannot be cleared, invalid checksums could still stay in the DB for Oracle.

  4. PVince81 commented on Jun 8, 2018

    @PVince81
    ContributorAuthor
  5. ownclouders commented on Jun 8, 2018

    @ownclouders
    Contributor

    GitMate.io thinks possibly related issues are #17027 (Cannot create empty file on SFTP), #21366 (Update), #20661 (Update), #10078 (cache updater updates etag too often), and #23284 (GoogleDrive folder appears empty after file update).

  6. PVince81 commented on Jun 8, 2018

    @PVince81
    ContributorAuthor

    @tomneedham @butonic do we agree on the proposed approach ? only fix for Oracle and only for when setting empty strings ?

  7. self-assigned this
    on Jun 11, 2018
  8. modified the milestones: backlog, development on Jun 11, 2018
  9. assigned and unassigned on Jun 12, 2018
  10. IljaN commented on Jun 19, 2018

    @IljaN
    Contributor

    Note aside: We should probably set the default value the checksum column to null (unless reasons) and hunt down all places where it is set to empty string.

  11. IljaN commented on Jun 22, 2018

    @IljaN
    Contributor

    It looks like the update only works if the mtime changes
    The resulting query is
    "UPDATE `*PREFIX*filecache` SET `mtime` = ?, `checksum`=? WHERE (`mtime` <> ? OR `checksum` <> ? OR `mtime` IS NULL OR `checksum` IS NULL) AND `fileid` = ?

  12. PVince81 commented on Jun 25, 2018

    @PVince81
    ContributorAuthor

    yes, this is because of detection of changes on external storages.

  13. IljaN commented on Jun 26, 2018

    @IljaN
    Contributor

    But we shouldn`t mess with the mtime when resetting the checksum right?

  14. PVince81 commented on Jun 26, 2018

    @PVince81
    ContributorAuthor

    @IljaN when restting the checksum manually from a specific command, we don't touch the mtime.

    What you observed is likely the normal behavior of the scanner: whenever the mtime of a file on disk is different than the one in the file cache, it is interpreted as "the file on disk was modified" so the scanner will update the file's metadata and clear the checksum. As a side effect of course the mtime would also be adjusted to whatever is now on disk.

  15. PVince81 commented on Jun 28, 2018

    @PVince81
    ContributorAuthor

    @IljaN link to PR ? I thought you had something already based on our discussions

  16. IljaN commented on Jul 5, 2018

    @IljaN
    Contributor

    Backport: #31996

  17. modified the milestones: development, QA on Jan 11, 2019
  18. locked as resolved and limited conversation to collaborators on Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type:Bugp3-medium

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions