Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassCastException: class java.time.Instant cannot be cast to class java.time.chrono.ChronoLocalDateTime #12311

Closed
ebuildy opened this issue Apr 11, 2020 · 4 comments · Fixed by #12834
Assignees
Labels
Projects
Milestone

Comments

@ebuildy
Copy link

ebuildy commented Apr 11, 2020

Describe the bug
A Java bug while generating field fingerprint :

java.lang.ClassCastException: class java.time.Instant cannot be cast to class java.time.chrono.ChronoLocalDateTime (java.time.Instant and java.time.chrono.ChronoLocalDateTime are in module java.base of loader 'bootstrap')

logs

java.lang.ClassCastException: class java.time.Instant cannot be cast to class java.time.chrono.ChronoLocalDateTime (java.time.Instant and java.time.chrono.ChronoLocalDateTime are in module java.base of loader 'bootstrap')
at java_time.chrono$fn__4893.invokeStatic(chrono.clj:35)
at java_time.chrono$fn__4893.invoke(chrono.clj:35)
at java_time.core$fn__2990$G__2970__2997.invoke(core.clj:136)
at java_time.core$before_QMARK_.invokeStatic(core.clj:165)
at java_time.core$before_QMARK_.invoke(core.clj:154)
at metabase.sync.analyze.fingerprint.fingerprinters$earliest.invokeStatic(fingerprinters.clj:143)
at metabase.sync.analyze.fingerprint.fingerprinters$earliest.invoke(fingerprinters.clj:138)
at redux.core$juxt$fn__45867$fn__45872.invoke(core.cljc:37)
at clojure.core$map$fn__5870.invoke(core.clj:2760)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:51)
at clojure.lang.RT.seq(RT.java:535)
at clojure.core$seq__5402.invokeStatic(core.clj:137)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
at clojure.core.protocols$fn__8146.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__8146.invoke(protocols.clj:75)
at clojure.core.protocols$fn__8088$G__8083__8101.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6828)
at clojure.core$into.invokeStatic(core.clj:6895)
at clojure.core$mapv.invokeStatic(core.clj:6903)
at clojure.core$mapv.invoke(core.clj:6903)
at redux.core$juxt$fn__45867.invoke(core.cljc:34)
at redux.core$post_complete$fn__45861.invoke(core.cljc:15)
at clojure.core$map$fn__5862$fn__5863.invoke(core.clj:2742)
at redux.core$post_complete$fn__45861.invoke(core.cljc:15)
at redux.core$juxt$fn__45867$fn__45872.invoke(core.cljc:37)
at clojure.core$map$fn__5870.invoke(core.clj:2760)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:51)
at clojure.lang.RT.seq(RT.java:535)
at clojure.core$seq__5402.invokeStatic(core.clj:137)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
at clojure.core.protocols$fn__8146.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__8146.invoke(protocols.clj:75)
at clojure.core.protocols$fn__8088$G__8083__8101.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6828)
at clojure.core$into.invokeStatic(core.clj:6895)
at clojure.core$mapv.invokeStatic(core.clj:6903)
at clojure.core$mapv.invoke(core.clj:6903)
at redux.core$juxt$fn__45867.invoke(core.cljc:34)
at redux.core$post_complete$fn__45861.invoke(core.cljc:15)
at metabase.sync.analyze.fingerprint.fingerprinters$with_error_handling$fn__46564$fn__46569.invoke(fingerprinters.clj:121)
at metabase.sync.util$do_with_error_handling.invokeStatic(util.clj:149)
at metabase.sync.util$do_with_error_handling.invoke(util.clj:142)
at metabase.sync.analyze.fingerprint.fingerprinters$with_error_handling$fn__46564.invoke(fingerprinters.clj:121)
at metabase.sync.analyze.fingerprint.fingerprinters$col_wise$fn__46527$fn__46532.invoke(fingerprinters.clj:32)
at clojure.core$map$fn__5873.invoke(core.clj:2766)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:51)
at clojure.lang.Cons.next(Cons.java:39)
at clojure.lang.RT.next(RT.java:713)
at clojure.core$next__5386.invokeStatic(core.clj:64)
at clojure.core.protocols$fn__8159.invokeStatic(protocols.clj:169)
at clojure.core.protocols$fn__8159.invoke(protocols.clj:124)
at clojure.core.protocols$fn__8114$G__8109__8123.invoke(protocols.clj:19)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
at clojure.core.protocols$fn__8146.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__8146.invoke(protocols.clj:75)
at clojure.core.protocols$fn__8088$G__8083__8101.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6828)
at clojure.core$into.invokeStatic(core.clj:6895)
at clojure.core$mapv.invokeStatic(core.clj:6903)
at clojure.core$mapv.invoke(core.clj:6903)
at metabase.sync.analyze.fingerprint.fingerprinters$col_wise$fn__46527.invoke(fingerprinters.clj:29)
at redux.core$post_complete$fn__45861.invoke(core.cljc:15)
at clojure.lang.PersistentVector.reduce(PersistentVector.java:343)
at clojure.core$transduce.invokeStatic(core.clj:6883)
at clojure.core$transduce.invokeStatic(core.clj:6879)
at clojure.core$transduce.invoke(core.clj:6870)
at metabase.sync.analyze.fingerprint$fn__51841$fingerprint_table_BANG___51846$fn__51847.invoke(fingerprint.clj:43)
at metabase.sync.analyze.fingerprint$fn__51841$fingerprint_table_BANG___51846.invoke(fingerprint.clj:41)
at metabase.sync.analyze.fingerprint$fn__52014$fingerprint_fields_BANG___52019$fn__52020.invoke(fingerprint.clj:162)
at metabase.sync.analyze.fingerprint$fn__52014$fingerprint_fields_BANG___52019.invoke(fingerprint.clj:158)
at metabase.sync.analyze.fingerprint$fn__52040$fingerprint_fields_for_db_BANG___52045$fn__52046$fn__52047$iter__52048__52052$fn__52053$fn__52054.invoke(fingerprint.clj:174)
at metabase.sync.analyze.fingerprint$fn__52040$fingerprint_fields_for_db_BANG___52045$fn__52046$fn__52047$iter__52048__52052$fn__52053.invoke(fingerprint.clj:173)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:51)
at clojure.lang.Cons.next(Cons.java:39)
at clojure.lang.RT.boundedLength(RT.java:1792)
at clojure.lang.RestFn.applyTo(RestFn.java:130)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$apply.invoke(core.clj:660)
at metabase.sync.analyze.fingerprint$fn__52040$fingerprint_fields_for_db_BANG___52045$fn__52046$fn__52047.invoke(fingerprint.clj:173)
at metabase.query_processor.store$do_with_store.invokeStatic(store.clj:46)
at metabase.query_processor.store$do_with_store.invoke(store.clj:40)
at metabase.sync.analyze.fingerprint$fn__52040$fingerprint_fields_for_db_BANG___52045$fn__52046.invoke(fingerprint.clj:170)
at metabase.sync.analyze.fingerprint$fn__52040$fingerprint_fields_for_db_BANG___52045.invoke(fingerprint.clj:165)
at metabase.sync.analyze$make_analyze_steps$fn__52186.invoke(analyze.clj:108)
at metabase.sync.util$fn__44441$run_step_with_metadata__44446$fn__44450$fn__44452.invoke(util.clj:345)
at metabase.sync.util$with_start_and_finish_logging_STAR_.invokeStatic(util.clj:102)
at metabase.sync.util$with_start_and_finish_logging_STAR_.invoke(util.clj:96)
at metabase.sync.util$with_start_and_finish_debug_logging.invokeStatic(util.clj:119)
at metabase.sync.util$with_start_and_finish_debug_logging.invoke(util.clj:116)
at metabase.sync.util$fn__44441$run_step_with_metadata__44446$fn__44450.invoke(util.clj:342)
at metabase.sync.util$fn__44441$run_step_with_metadata__44446.invoke(util.clj:337)
at metabase.sync.util$fn__44633$run_sync_operation__44638$fn__44639$fn__44640.invoke(util.clj:430)
at clojure.core$mapv$fn__8445.invoke(core.clj:6912)
at clojure.lang.PersistentVector.reduce(PersistentVector.java:343)
at clojure.core$reduce.invokeStatic(core.clj:6827)
at clojure.core$mapv.invokeStatic(core.clj:6903)
at clojure.core$mapv.invoke(core.clj:6903)
at metabase.sync.util$fn__44633$run_sync_operation__44638$fn__44639.invoke(util.clj:430)
at metabase.sync.util$fn__44633$run_sync_operation__44638.invoke(util.clj:424)
at metabase.sync.analyze$fn__52198$analyze_db_BANG___52203$fn__52204$fn__52205.invoke(analyze.clj:125)
at metabase.sync.util$do_with_error_handling.invokeStatic(util.clj:149)
at metabase.sync.util$do_with_error_handling.invoke(util.clj:142)
at metabase.sync.util$do_with_error_handling.invokeStatic(util.clj:145)
at metabase.sync.util$do_with_error_handling.invoke(util.clj:142)
at clojure.core$partial$fn__5839.invoke(core.clj:2623)
at metabase.driver.mongo$eval2344$fn__2345$f__1744__auto____2346.invoke(mongo.clj:91)
at metabase.driver.mongo.util$_with_mongo_connection$fn__1735.invoke(util.clj:205)
at metabase.util.ssh$with_ssh_tunnel_STAR_.invokeStatic(ssh.clj:106)
at metabase.util.ssh$with_ssh_tunnel_STAR_.invoke(ssh.clj:91)
at metabase.driver.mongo.util$_with_mongo_connection.invokeStatic(util.clj:199)
at metabase.driver.mongo.util$_with_mongo_connection.invoke(util.clj:194)
at metabase.driver.mongo$eval2344$fn__2345.invoke(mongo.clj:90)
at clojure.lang.MultiFn.invoke(MultiFn.java:239)
at metabase.sync.util$sync_in_context$fn__44353.invoke(util.clj:138)
at metabase.sync.util$with_db_logging_disabled$fn__44350.invoke(util.clj:129)
at metabase.sync.util$with_start_and_finish_logging_STAR_.invokeStatic(util.clj:102)
at metabase.sync.util$with_start_and_finish_logging_STAR_.invoke(util.clj:96)
at metabase.sync.util$with_start_and_finish_logging$fn__44339.invoke(util.clj:114)
at metabase.sync.util$with_sync_events$fn__44334.invoke(util.clj:88)
at metabase.sync.util$with_duplicate_ops_prevented$fn__44325.invoke(util.clj:67)
at metabase.sync.util$do_sync_operation.invokeStatic(util.clj:164)
at metabase.sync.util$do_sync_operation.invoke(util.clj:161)
at metabase.sync.analyze$fn__52198$analyze_db_BANG___52203$fn__52204.invoke(analyze.clj:122)
at metabase.sync.analyze$fn__52198$analyze_db_BANG___52203.invoke(analyze.clj:117)
at metabase.api.database$fn__54643$fn__54645.invoke(database.clj:590)
at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
at clojure.lang.AFn.call(AFn.java:18)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

To Reproduce

  1. Use MongoDB
  2. Run a database synchro.

I dont know what it cause the exception, deletedAt is a classic Date field (and it works fine for other field).

Expected behavior
fingerprint field should success

Severity
field cannot be used

Additional context
MongoDB as data base

@ebuildy ebuildy added .Needs Triage Type:Bug Product defects labels Apr 11, 2020
@flamber
Copy link
Contributor

flamber commented Apr 11, 2020

Hi @ebuildy
Please post "Diagnostic Info" from Admin > Troubleshooting.
Which version of MongoDB?

@ebuildy
Copy link
Author

ebuildy commented Apr 13, 2020

MongoDB 3.4

{
  "browser-info": {
    "language": "fr",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0",
    "vendor": ""
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.5+10",
    "java.vendor": "AdoptOpenJDK",
    "java.vendor.url": "https://adoptopenjdk.net/",
    "java.version": "11.0.5",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.5+10",
    "os.name": "Linux",
    "os.version": "4.19.76-linuxkit",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "h2",
      "mongo"
    ],
    "hosting-env": "unknown",
    "application-database": "h2",
    "application-database-details": {
      "database": {
        "name": "H2",
        "version": "1.4.197 (2018-03-18)"
      },
      "jdbc-driver": {
        "name": "H2 JDBC Driver",
        "version": "1.4.197 (2018-03-18)"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2020-04-10",
      "tag": "v0.35.2",
      "branch": "release-0.35.x",
      "hash": "f3b2857"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

@sbelak
Copy link
Contributor

sbelak commented May 22, 2020

How do values of this field look like? I managed to reproduce such an error when what gets returned from the DB is a mix of strings and numbers (presumably ms from epoch).

@ebuildy
Copy link
Author

ebuildy commented May 24, 2020

Yes you are probably right. MongoDB have no schema/mapping field type, hence, field value can be messed up, in my case, I am pretty sure this is the case.

@sbelak sbelak self-assigned this Jun 29, 2020
@salsakran salsakran added this to TODO in 0.36.0 Jun 29, 2020
@sbelak sbelak removed their assignment Jun 29, 2020
@robdaemon robdaemon self-assigned this Jun 29, 2020
robdaemon pushed a commit that referenced this issue Jul 2, 2020
During fingerprinting, we can end up trying to compare two datatypes
that are not comparable - ChronoLocalDateTime and Instant. Coerce the
ChronoLocalDateTime to a proper Instant for the comparison to work.

When earliest / latest are called, the acc parameter must be coerced to
a Temporal object also.

Resolves #12311

[ci all]
0.36.0 automation moved this from TODO to Done Jul 6, 2020
camsaul pushed a commit that referenced this issue Jul 6, 2020
* Handle comparing ChronoLocalDateTime and Instants

During fingerprinting, we can end up trying to compare two datatypes
that are not comparable - ChronoLocalDateTime and Instant. Coerce the
ChronoLocalDateTime to a proper Instant for the comparison to work.

When earliest / latest are called, the acc parameter must be coerced to
a Temporal object also.

Resolves #12311

[ci all]

* making ->temporal recursive

* Get the timezone in an precedence order

When converting a LocalTime for fingerprinting, convert to an Instant
using the following precedence order:

* report timezone
* database timezone
* system timezone

[ci all]

* use UTC for timezones
@flamber flamber added this to the 0.36.0 milestone Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
0.36.0
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants