Skip to content

Adding a column to the filecache is super time consuming (depending on db) #22747

Closed

Description

@butonic

The resulting ALTER TABLE for the added checksum column in OC9 will create a temp table with the same columns as the filecache, add the colum, COPY the table content and finally rename it and delete the original table. Big installations will experience a very long downtime as we have seen today with a huge activity table change when updating to oc 8.2.2.

In this case mysql 5.5 was used. In the documentation for it I see no way around copying the contents: http://dev.mysql.com/doc/refman/5.5/en/alter-table.html#idm140603778401088 It seems this has still not changed with mysql 5.7: http://dev.mysql.com/doc/refman/5.7/en/innodb-create-index-overview.html#idm140023654764880 although it should be less of a performance hog.

cc @MorrisJobke @DeepDiver1975 @karlitschek

Activity

  1. added this to the milestone on Mar 1, 2016
  2. butonic commented on Mar 1, 2016

    @butonic
    ContributorAuthor

    Postgres may omit rebuilding the table if no default value is specified: http://www.postgresql.org/docs/9.5/static/sql-altertable.html#AEN72358

  3. karlitschek commented on Mar 1, 2016

    @karlitschek
    Contributor

    yes. this is actually the wanted behavior. we want to simulate the upgrade because we actually touch the real table. the reason is that we had a ton of bugs before triggered by combinations of specific db types and servers with specific limitations. certain sometimes broken entries in the table, size limitations ir the combination of all if that.
    so we destroyed user data in the past.
    the fix is to copy the table first and test it. it is accepted that this takes some times but is better then destroying the database.
    experienced admin can skip this if they tested the upgrade manually befores

  4. MorrisJobke commented on Mar 1, 2016

    @MorrisJobke
    Contributor

    the fix is to copy the table first and test it. it is accepted that this takes some times but is better then destroying the database.

    It's not our code that copies the table. It's mysql that copies the table. We run the upgrade simulation steps -> that itself triggers a copy of the same table in mysql (1) and apply the schema update (ALTER TABLE) which itself will copy the table internally(2). Then we run the same on the actual code (3+4).

    This means we copy the whole table 4 times instead of 1 time. This totally kills bigger installations on mysql.

    I guess we either need a way to figure out why mysql copies the table sometimes when a column is added (I guess this is the case when the whole table doesn't fit in memory).

  5. MorrisJobke commented on Mar 1, 2016

    @MorrisJobke
    Contributor

    @karlitschek @DeepDiver1975 You asked me about this. It seems that I was wrong here. Today I noticed that the complete activity table was copied while running the alter table statement to add two columns (owncloud/activity@0470887).

  6. MorrisJobke commented on Mar 1, 2016

    @MorrisJobke
    Contributor

    We should re-evaluate the add of the column to the file cache because this could add a serious problem.

    Ref #21997

    @karlitschek @DeepDiver1975 Sorry - I did a mistake by stating that this will not be a problem. 😢

  7. MorrisJobke commented on Mar 1, 2016

    @MorrisJobke
    Contributor

    @PVince81 @nickvergessen I remind that Frank said that you tested this and it worked fine. What exactly was the test scenario?

  8. PVince81 commented on Mar 1, 2016

    @PVince81
    Contributor

    I think @karlitschek tested it himself and it was fast.

  9. DeepDiver1975 commented on Mar 1, 2016

    @DeepDiver1975
    Contributor

    adding sev1 - this needs to be sorted out

  10. MorrisJobke commented on Mar 1, 2016

    @MorrisJobke
    Contributor

    I updated my description above - it's a ratio of 1 to 4.

  11. PVince81 commented on Mar 1, 2016

    @PVince81
    Contributor

    To clarify: this report is NOT about simulated update.
    It's about the ALTER TABLE that happens afterwards.

  12. 40 remaining items

  13. MorrisJobke commented on Mar 21, 2016

    @MorrisJobke
    Contributor

    Why not have a new table for the checksum?

    Because it's too late.

  14. VicDeo commented on Mar 21, 2016

    @VicDeo
    Contributor

    @PVince81 @DeepDiver1975 So, what finally needs to be done?

    Add the following to update notification in Web UI for stable8.2 && MySQL && oc_filecache ahs more than 200k entries?:

    According to your filecache table size upgrade might take too long. You can execute the following query on your database to speedup the upgrade process: ALTER TABLE oc_filecache ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions; `

  15. PVince81 commented on Mar 22, 2016

    @PVince81
    Contributor

    Sounds good to me. @karlitschek @DeepDiver1975 @butonic @MorrisJobke what do you think ?

  16. karlitschek commented on Mar 22, 2016

    @karlitschek
    Contributor

    we discussed this and we don't want to have a new table for the. we optimize for production speed instead of upgrade speed

  17. karlitschek commented on Mar 22, 2016

    @karlitschek
    Contributor

    I think we should add a warning to the web ui and the cli if you have more then 200k. Please check the original updater 2.0 issue for the right place in the flow where we have the hint about the length of the upgrade.
    We should use this text instead:

    You have an ownCloud installation with over 200.000 files so the upgrade might take a while. The recommendation is to use the command-line instead of the web interface for big ownCloud servers. Hint: You can speed up the upgrade by executing this SQL command manually: ALTER TABLE oc_filecache ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions; `

    Not. Please show the hint only if using mysql.
    Please show the CLI hint only in the web ui.

    Does this make sense?

  18. VicDeo commented on Mar 23, 2016

    @VicDeo
    Contributor

    @karlitschek shouldn't this notice be added to 8.2 in order to be displayed before any action takes place?

  19. karlitschek commented on Mar 23, 2016

    @karlitschek
    Contributor

    I think 9.0.x is fine

  20. nickvergessen commented on Mar 23, 2016

    @nickvergessen
    Contributor

    But the update to 9.0.x is the one causing the troubles?! 😕

  21. MorrisJobke commented on Mar 23, 2016

    @MorrisJobke
    Contributor

    But the update to 9.0.x is the one causing the troubles?!

    And then already the new 9.0.x code is available before the upgrade step has run. So this should be fine ;)

  22. ghost added this to the milestone on Apr 11, 2016
  23. ghost removed this from the 9.0.1 milestone on Apr 11, 2016
  24. PVince81 commented on Apr 19, 2016

    @PVince81
    Contributor

    So if I understand well the warning has been added 9.0.1, closing hence.

    Please reopen if you think there is something left to do.

  25. lock commented on Aug 4, 2019

    @lock

    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.

  26. locked as resolved and limited conversation to collaborators on Aug 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions