Skip to content

Conversation

@individual-it
Copy link
Member

Description

allow to store mtime as 64bit int
build on top of #28066

Related Issue

#23228

Motivation and Context

the database should hold 64bit int to be able to store dates after 2038

How Has This Been Tested?

run new tests against pgsql, mysql & sqlite on PHP 7.1

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

db_structure.xml Outdated
<default></default>
<notnull>true</notnull>
<length>4</length>
<length>8</length>
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to use the new DB migrations approach to make DB changes, don't reuse the old db_structure.xml.

See https://doc.owncloud.org/server/10.0/developer_manual/app/schema.html

@PVince81
Copy link
Contributor

PVince81 commented Jun 2, 2017

If all databases can deal with it then why not.

@individual-it
Copy link
Member Author

@PVince81 is that the correct way of changing the DB Structure?

according to the documentation bigint will be converted to PHP's string type

I can imagine 2 problems with that:

  1. on 32bit systems we could theoretically have a wrong mtime if a long string is casted to int. But that should not happen because there is no way to enter a value bigger than PHP_INT_MAX. Except of course somebody writes the value directly to the DB or moves a DB with files that are far in the future or past from a 64bit system to a 32bit system. So I think this is more of a theoretical problem.
  2. in places where mtime is used without being casted to int but compared with === the code will fail

@individual-it
Copy link
Member Author

rebased on current master

Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

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

Looks good, assuming the Jenkins runs some time and passes. As long as the actual storage filesystems also support setting 64-bit then that gets us well past the end of the sun and practical heat death of the universe.
http://ximalas.info/2015/03/10/when-does-the-64-bit-unix-time_t-really-end/

@PVince81
Copy link
Contributor

PVince81 commented Jul 4, 2017

Would be good to do a quick test on a 32 bit system (VM or rasperry pi) to confirm that it doesn't break anything

@PVince81
Copy link
Contributor

PVince81 commented Jul 4, 2017

uh oh owncloud/files_texteditor#172 ?! do we need to support float mtimes ?

@phil-davis
Copy link
Contributor

phil-davis commented Jul 4, 2017

We thought about this. Modern file systems happily keep a record of mtime and the like to some fractions of a second. e.g. I think something like:
ext4 nanoseconds
UFS - ?
FAT - 2 seconds
exFAT - 10 milliseconds
NTFS - 100 nanoseconds

Rather than using float, the database could store the int nanoseconds (traditional unix timestamp seconds x 10^9). According to my calculations, (2^63)/(60 * 60 * 24 * 365 * 10^9) is about 292. That would allow storing times +-292 years from 1970. Enough for normal files, and dates that current people might have been born etc,

Or it can store the current seconds (in 64 bit to include the beginning and end of the universe) and add another 64-bit field for the nanoseconds offset.

That allows actual timestamps from ext4 and similar to be remembered in the database.

Some issues are:

  1. What is the actual resolution of the backend storage that the server happens to have? What to do about having a potentially more accurate timestamp in the database than in the file system?
  2. Clients will have local file systems with different resolutions. So if they are provided nanosecond resolution when they download a file, actually they cannot store that in their local filesystem. So what will they do in the future when comparing local and server time stamps? (if the client also has its own database, then it can remember the nanosecond timestamps itself)

@individual-it
Copy link
Member Author

I've run the unit tests on a 32bit system with PHP 5.6 and they are passing on sqlite & mysql
on a 32bit system it would not be possible to store dates > 2038 because the mtime is always cast to int #28066

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

Fine 👍

Please rebase once to refresh CI

@individual-it
Copy link
Member Author

rebased, @DeepDiver1975 are you happy with the changes?

Copy link
Member

@DeepDiver1975 DeepDiver1975 left a comment

Choose a reason for hiding this comment

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

We might want to rebase this one and see for conflicts

@individual-it
Copy link
Member Author

@DeepDiver1975 rebased the branch.
UI tests are failing because of #28748

@DeepDiver1975 DeepDiver1975 merged commit 3b4eb39 into master Aug 22, 2017
@DeepDiver1975 DeepDiver1975 deleted the 64bit-mtime branch August 22, 2017 09:59
@DeepDiver1975
Copy link
Member

@PVince81 shall we backport this?

@PVince81
Copy link
Contributor

Later maybe, I don't feel safe about this

@PVince81
Copy link
Contributor

PVince81 commented Sep 9, 2017

@individual-it please backport for 10.0.4 so we can have it in an early beta

@phil-davis
Copy link
Contributor

Backport stable10 #28961

@phil-davis
Copy link
Contributor

Note: the migration code is being moved from dav to core in #29120

@DeepDiver1975 DeepDiver1975 modified the milestones: 10.1, development Oct 10, 2017
@lock
Copy link

lock bot commented Aug 2, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants