Skip to content

fileid of oc_filecache in danger of hitting max value #26901

Closed

Description

@schnidrig

Database

5 node galera cluster with mariadb.
maxscale with read/write splitter.

Expected behaviour

virtually unlimited lifetime of oc service

Actual behaviour

the primary key of the filecache table is in danger of overflowing.
At that point our oc instance will refuse any addition of new files.

Problem description

MariaDB [owncloud]> show create table oc_filecache\G
*************************** 1. row ***************************
	   Table: oc_filecache
Create Table: CREATE TABLE `oc_filecache` (
  `fileid` int(11) NOT NULL AUTO_INCREMENT,
  `storage` int(11) NOT NULL DEFAULT '0',
  `path` varchar(4000) COLLATE utf8_bin DEFAULT NULL,
  `path_hash` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
  `parent` int(11) NOT NULL DEFAULT '0',
  `name` varchar(250) COLLATE utf8_bin DEFAULT NULL,
  `mimetype` int(11) NOT NULL DEFAULT '0',
  `mimepart` int(11) NOT NULL DEFAULT '0',
  `size` bigint(20) NOT NULL DEFAULT '0',
  `mtime` int(11) NOT NULL DEFAULT '0',
  `storage_mtime` int(11) NOT NULL DEFAULT '0',
  `encrypted` int(11) NOT NULL DEFAULT '0',
  `unencrypted_size` bigint(20) NOT NULL DEFAULT '0',
  `etag` varchar(40) COLLATE utf8_bin DEFAULT NULL,
  `permissions` int(11) DEFAULT '0',
  PRIMARY KEY (`fileid`),
  UNIQUE KEY `fs_storage_path_hash` (`storage`,`path_hash`),
  KEY `fs_parent_name_hash` (`parent`,`name`),
  KEY `fs_storage_mimetype` (`storage`,`mimetype`),
  KEY `fs_storage_mimepart` (`storage`,`mimepart`),
  KEY `fs_storage_size` (`storage`,`size`,`fileid`)
) ENGINE=InnoDB AUTO_INCREMENT=252069614 DEFAULT CHARSET=utf8 COLLATE=utf8_bin
1 row in set (0.00 sec)

The primary key is a signed integer with max value of 2147483647.

MariaDB [owncloud]> select max(fileid), count(fileid) from oc_filecache;
+-------------+---------------+
| max(fileid) | count(fileid) |
+-------------+---------------+
|   252065705 |      60772002 |
+-------------+---------------+

We have 60 mio files and the fileid is currently at 250 mio.
4 months ago that counter was at 146 mio. During the last 4 months we had a 3 node galera cluster.
That means 100 Mio increase in 4 months; with our new 5 node cluster instead of a old 3 nodes cluster that would have been a: 100/3*5 = 170 mio increase. Therefore we'll hit the 2147483647 boundary in about 3.5 years with the current user base and setup. However, given the growth rate of our service, I'd estimate that to be more something like 2 years at best.

Considering, that enterprise customers (at least those I know of) usually are one year behind the current release, I think it is about time to fix this in the db.

Please consider changing the fileid to BIGINT. Or at the very least make it unsigned.

More of a hack than a workaround would be to change the auto_increment settings.

MariaDB [owncloud]> show variables like '%auto_increment%';
+------------------------------+-------+
| Variable_name                | Value |
+------------------------------+-------+
| auto_increment_increment     | 5     |
| auto_increment_offset        | 1     |
| wsrep_auto_increment_control | ON    |
+------------------------------+-------+

But of course, that would give me tons of other head aches.

Activity

  1. PVince81 commented on Jan 9, 2017

    @PVince81
    Contributor

    Uh oh...

    @butonic @DeepDiver1975 @PhilippSchaffrath

  2. added this to the 10.0 milestone on Jan 9, 2017
  3. PVince81 commented on Jan 9, 2017

    @PVince81
    Contributor

    @butonic this is the wrong ticket to discuss this, it will likely get lost. Maybe post here instead: #12487 (or find or create a matching ticket).

    Yes for using bigint for fileid if that can fix the issue in this one ticket.

  4. Helios07 commented on Jan 9, 2017

    @Helios07

    It is even worse for us:

    MariaDB [rwth_aachen]> select max(fileid), count(fileid) from oc_filecache;
    +-------------+---------------+
    | max(fileid) | count(fileid) |
    +-------------+---------------+
    |   529100321 |      51808811 |
    +-------------+---------------+
    

    (and we split our users to different instances already)

  5. PVince81 commented on Jan 9, 2017

    @PVince81
    Contributor

    We usually don't change DB schemas in a minor version, but might need to do an exception here... @felixboehm @DeepDiver1975 @butonic

    I suggest to provide a PR for a quickfix that changes the column type to bigint (not sure about performance impact here during upgrade...) and address @butonic's other points separately.

  6. davidjericho commented on Jan 20, 2017

    @davidjericho

    This one hadn't crossed my mind, but it's definitely a problem for us too.

    +-------------+---------------+
    | max(fileid) | count(fileid) |
    +-------------+---------------+
    |   676222618 |      45597155 |
    +-------------+---------------+
    

    It'll be a huge problem with our planned growth this year.

  7. butonic commented on Jan 31, 2017

    @butonic
    Contributor

    Um ... this will require us to alter the sharing table and probably other tables that reference the fileid ... foreign keys anyone?

  8. PVince81 commented on Jan 31, 2017

    @PVince81
    Contributor

    Ref: foreign keys #13143

    Indeed, not only the oc_filecache will be affected.

    Other tables that come to mind:

    • oc_vcategory_to_object which can use fileid as the object id
    • oc_share, the file_source and item_source columns
    • oc_properties will use fileid in the future: oc_properties must use fileid instead of path #25563
    • oc_systemtag_object_mapping
    • oc_mounts.root_id
    • oc_comments.object_id
    • activity table also uses fileid somewhere
    • ...
  9. PVince81 commented on Feb 10, 2017

    @PVince81
    Contributor

    Need to also evaluate the impact of bigger values on the clients especially Javascript.

  10. PVince81 commented on Feb 10, 2017

    @PVince81
    Contributor

    Or use strings for ids: #22330. Not sure about the performance impact with indices though.

  11. butonic commented on Apr 24, 2017

    @butonic
    Contributor

    just using bigint in dhe db is not enuogh. we neet to check if the code does cast to int, eg: https://github.com/owncloud/core/blob/master/lib/private/Files/Cache/Cache.php#L145

    +1 for strings for ids and get this right.

  12. 36 remaining items

  13. PVince81 commented on Aug 23, 2017

    @PVince81
    Contributor

    @VicDeo are we done with phase 1?

  14. VicDeo commented on Aug 23, 2017

    @VicDeo
    Contributor

    @PVince81 in general yes, but richdocuments and music should be ported to migrations for completion.
    And probably branching is needed to keep non-bigintified versions that are compatible with OC below 10.0.3

  15. PVince81 commented on Aug 30, 2017

    @PVince81
    Contributor

    moving to "planned" for second phase.

  16. modified the milestones: , development on Aug 30, 2017
  17. ckamm commented on Sep 5, 2017

    @ckamm

    @PVince81 What's the effect on the full id of this change? Currently 'getFileId()' in apps/dav/lib/Connector/Sabre/Node.php still does $id = sprintf('%08d', $this->info->getId()); - so I assume the zero-padding to 8 digits continues, but full ids will now increase in width when the numeric id exceeds 8 digits.

    This works for the desktop client (takes all digits until first non-numeric character).

  18. PVince81 commented on Sep 5, 2017

    @PVince81
    Contributor

    @ckamm we should probably get rid of that weird compound id with padding and move to "oc:id" and have the instance id part exposed through the capabilities API ? (separate ticket)

  19. phil-davis commented on Sep 5, 2017

    @phil-davis
    Contributor

    8 digits is only 99,999,999 = 100 million minus 1. 32 bit numbers anyway go to around 2,000,000,000 (signed) or 4,000,000,000 (unsigned) and thus would already be using 9 or 10 digits anyway (for installs with > 99,999,999 ids). So the 8-digit thing should be an existing "feature" regardless of 64-bit changes.

  20. ckamm commented on Sep 5, 2017

    @ckamm

    @phil-davis Good point.

    @PVince81 Currently oc:id is the compound id and oc:fileid is the numeric one (opposite to the code in Node.php). We could start deprecating oc:id, the cost would be significant migration work in the client. I agree about moving this discussion to a separate ticket.

    The bigint change looks good from the desktop client's point of view.

  21. PVince81 commented on Nov 3, 2017

    @PVince81
    Contributor

    Raised #29437 to follow up with phase 2 and other ids.

    All the main ids (fileids and activity table ids) have been adjusted already, closing.

  22. lock commented on Jul 31, 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.

  23. locked as resolved and limited conversation to collaborators on Jul 31, 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