Skip to content

PHOENIX-6486 Phoenix uses inconsistent chronologies internally, break… - #1289

Merged
richardantal merged 1 commit into
apache:masterfrom
richardantal:PHOENIX-6486-2
Aug 31, 2021
Merged

PHOENIX-6486 Phoenix uses inconsistent chronologies internally, break…#1289
richardantal merged 1 commit into
apache:masterfrom
richardantal:PHOENIX-6486-2

Conversation

@richardantal

Copy link
Copy Markdown
Contributor

…ing pre-Gregorian date handling

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 31sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 1sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
-1 ❌test4tests0m 0sThe patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ master Compile Tests _
+1 💚mvninstall20m 56smaster passed
+0hbaserecompile27m 26sHBase recompiled.
+1 💚compile1m 1smaster passed
+1 💚checkstyle0m 59smaster passed
+1 💚javadoc0m 50smaster passed
+0 🆗spotbugs3m 7sphoenix-core in master has 972 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall13m 39sthe patch passed
+0hbaserecompile23m 9sHBase recompiled.
+1 💚compile1m 3sthe patch passed
+1 💚javac1m 3sthe patch passed
-1 ❌checkstyle1m 0sphoenix-core: The patch generated 6 new + 144 unchanged - 19 fixed = 150 total (was 163)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 51sthe patch passed
+1 💚spotbugs3m 22sthe patch passed
_ Other Tests _
-1 ❌unit112m 57sphoenix-core in the patch failed.
+1 💚asflicense0m 45sThe patch does not generate ASF License warnings.
177m 6s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/1/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#1289
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaserebuild hbaseanti checkstyle compile
unameLinux 07c5ec37973d 4.15.0-151-generic #157-Ubuntu SMP Fri Jul 9 23:07:57 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev/phoenix-personality.sh
git revisionmaster / bfc4621
Default JavaPrivate Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08
checkstylehttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/1/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
unithttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/1/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt
Test Resultshttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/1/testReport/
Max. process+thread count14094 (vs. ulimit of 30000)
modulesC: phoenix-core U: phoenix-core
Console outputhttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/1/console
versionsgit=2.7.4 maven=3.3.9 spotbugs=4.1.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@dbwong

Copy link
Copy Markdown
Contributor

Question, likely we should follow what HBase/Hadoop does for storage/manipulation of temporal data. Does hbase use joda time internally or are they on only jdk, or another library?

@joshelser

Copy link
Copy Markdown
Member

Does hbase use joda time internally or are they on only jdk, or another library?

HBase doesn't have any notion of time (in this sense). The timestamp on an HBase cell is just a number.

@dbwong

Copy link
Copy Markdown
Contributor

If we don't have any wire dependencies then any reason we are preferring jodatime? I think long term we likely would want to consider something more robust for SQL temporal standards for interval queries (like oracle BETWEEN) or perhaps more common like jdk8/jsr-310. @joshelser@richardantal

@stoty

Copy link
Copy Markdown
Contributor

If we don't have any wire dependencies then any reason we are preferring jodatime? I think long term we likely would want to consider something more robust for SQL temporal standards for interval queries (like oracle BETWEEN) or perhaps more common like jdk8/jsr-310. @joshelser@richardantal

Unfortunately we cannot use JSR310, because it's only available from JDK8, and we still have to support JDK7 for 4.x.

IMO the robustnes of Joda Time is not a problem, it's conceptually very similar to JSR310 (or rather the other way around), and actually has the same author.

@stoty

Copy link
Copy Markdown
Contributor

@joshelser@dbwong
Also see the analysis in the ticket on choosing which Chronology to use internally,
and the cons and pros of the solution in this patch (using GJChronology internally)
i.e. we will have to do some extra work when we finally convert to JSR310.

@stoty

Copy link
Copy Markdown
Contributor

@richardantal Can you add some tests to see how this works with new java.time APIs and the conversions methods from/to java.sql.* ?
(Obviously for master only)

@dbwong

Copy link
Copy Markdown
Contributor

Mmy comment on robustness was not pointing toward jodatime or jsr being more robust than another but rather in consideration of other datetime libraries from a future feature point of view as I know many SQL users have wanted in the past from my experience implementing many date time functions in other large databases. Apologies if I missed any library discussion on the JIRA but I mostly saw a great job covering the underlying currently used libraries and the time representation we were using. Maybe these were library discussions, thus class names, when I was assuming you were only discussing the calendar system.
Note that joda time also wants people to migrate to js-310 and the implementer supports a maven backwards compatibility package for jdk7 though I haven't done full investigation on the performance.
One last question, can customer data could be "corrupt" based on how the data get entered into the table if from SQL constant vs function based path? Would this change break customer data if one path was used and not another?

@stoty

Copy link
Copy Markdown
Contributor

@dbwong
I absolutely support migrating to JSR-310, as soon 4.x is out of the picture.
I got the impression that Java 7 JSR310 library is not really a production quality thing, but I may be wrong.
The JSR310 vs Java7 discussion happened in another JIRA earlier, not this one.

Yes, existing time data will be impacted.

AFACT we only use JodaTime (with ISO chronology) in the write path, and we always read with the java.util.Date classes, and the current approach uses the java.util.Date compatible chronology for both read and write.

However, some date/time functions do use Joda time internally, so the function output may be affected by the change, even if reading the values directly is not.

I wouldn't worry about it too mach, as only pre-gregorian dates are affected, and the current mess makes using those impractical anyway.

One issue with the approach in this patch is that we will need to re-implement GJChronology for the JSR310 migration, as it doesn't have that chronology by default.

@stoty

Copy link
Copy Markdown
Contributor

To recap:

In this patch we use GJChronology internally, so

  • upserting java.sql.Timestamp(10,10,10,10,10,10) will be read back as rs.getString() == "10-10-10 10:10:10" as a, but
  • upserting java.sql.Timestamp.valueOf(java.time.LocalDateTme.of(10,10,10,10,10,10)) will be read back as rs.getString() == (10-10-12 10:10:10"

If we used ISOChronology internally instead , then

  • upserting java.sql.Timestamp(10,10,10,10,10,10) would be read back as rs.getString() == "10-10-08 10:10:10", but
  • upserting java.sql.Timestamp.valueOf(java.time.LocalDateTime.of(10,10,10,10,10,10)) will be read back as rs.getString() == "10-10-10 10:10:10"

(The above examples assume that the local TZ is UTC)

So we will will behave unexpectedly in some cases either way, no matter what we do, there will be surprises when using either the old java.util.Date , or the new java.time.API .

The current patch favors the old API.

@richardantal

Copy link
Copy Markdown
ContributorAuthor

We had a private discussion about it with Istvan.
Thank you @stoty for the recap.

Added a test with java.time API to visualise some scenario.

Small correction about the current behaviour:

  • upserting java.sql.Timestamp.valueOf(java.time.LocalDateTme.of(10,10,10,10,10,10)) will be read back as rs.getString() == "10-10-10 10:10:10"
  • dayofmonth will return 10

but

  • upserting new java.sql.Timestamp(java.time.Instant.parse("0010-10-10T10:10:10.111Z").toEpochMilli()) will be read back as rs.getString() == "10-10-12 10:10:10"
  • dayofmonth will return 12

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec6m 42sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
-1 ❌test4tests0m 0sThe patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ master Compile Tests _
+1 💚mvninstall21m 54smaster passed
+0hbaserecompile28m 53sHBase recompiled.
+1 💚compile1m 11smaster passed
+1 💚checkstyle1m 2smaster passed
+1 💚javadoc0m 54smaster passed
+0 🆗spotbugs3m 17sphoenix-core in master has 972 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall14m 15sthe patch passed
+0hbaserecompile24m 11sHBase recompiled.
+1 💚compile1m 5sthe patch passed
+1 💚javac1m 5sthe patch passed
-1 ❌checkstyle1m 1sphoenix-core: The patch generated 6 new + 144 unchanged - 19 fixed = 150 total (was 163)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 52sthe patch passed
+1 💚spotbugs3m 24sthe patch passed
_ Other Tests _
+1 💚unit124m 38sphoenix-core in the patch passed.
+1 💚asflicense0m 23sThe patch does not generate ASF License warnings.
195m 35s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/2/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#1289
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaserebuild hbaseanti checkstyle compile
unameLinux 426233ea480c 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev/phoenix-personality.sh
git revisionmaster / 9dfb423
Default JavaPrivate Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08
checkstylehttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/2/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
Test Resultshttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/2/testReport/
Max. process+thread count9132 (vs. ulimit of 30000)
modulesC: phoenix-core U: phoenix-core
Console outputhttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/2/console
versionsgit=2.7.4 maven=3.3.9 spotbugs=4.1.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@richardantal

Copy link
Copy Markdown
ContributorAuthor

Thanks @dbwong and @stoty for the reviews. I squashed the commits to 1.
Will create a PR for 4.x to see test run and merge them together.

@stoty

Copy link
Copy Markdown
Contributor

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 19sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 1sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
-1 ❌test4tests0m 0sThe patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ master Compile Tests _
+1 💚mvninstall20m 50smaster passed
+0hbaserecompile27m 28sHBase recompiled.
+1 💚compile1m 2smaster passed
+1 💚checkstyle1m 0smaster passed
+1 💚javadoc0m 50smaster passed
+0 🆗spotbugs3m 4sphoenix-core in master has 972 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall17m 28sthe patch passed
+0hbaserecompile27m 52sHBase recompiled.
+1 💚compile1m 9sthe patch passed
+1 💚javac1m 9sthe patch passed
-1 ❌checkstyle1m 4sphoenix-core: The patch generated 8 new + 142 unchanged - 21 fixed = 150 total (was 163)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 53sthe patch passed
+1 💚spotbugs3m 22sthe patch passed
_ Other Tests _
-1 ❌unit116m 35sphoenix-core in the patch failed.
+1 💚asflicense0m 43sThe patch does not generate ASF License warnings.
186m 44s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/3/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#1289
Optional Testsdupname asflicense javac javadoc unit spotbugs hbaserebuild hbaseanti checkstyle compile
unameLinux 4cc0ae40448c 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev/phoenix-personality.sh
git revisionmaster / 9dfb423
Default JavaPrivate Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08
checkstylehttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/3/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt
unithttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/3/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt
Test Resultshttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/3/testReport/
Max. process+thread count12045 (vs. ulimit of 30000)
modulesC: phoenix-core U: phoenix-core
Console outputhttps://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-1289/3/console
versionsgit=2.7.4 maven=3.3.9 spotbugs=4.1.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@richardantal
richardantal merged commit 67cef07 into apache:masterAug 31, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@richardantal@stoty@dbwong@joshelser