caribou / caribou-core

Core functionality for Caribou
44 stars 3 forks source link

model/init hits a stacktrace when I use c3p0 connection pooling #24

Closed noisesmith closed 10 years ago

noisesmith commented 10 years ago

WIth my plugin lib https://github.com/caribou/caribou-plugin I was able to create a c3p0 plugin that puts a c3p0 connection pool object into the :database field of the config map. https://github.com/caribou/caribou-c3p0-plugin

This mostly works, and caribou uses the connection pool, but I get some extraneous stack traces with model/init (though as far as I can tell model/init succeeds - the cached models get populated, queries work, etc).

elided.core=> (c (caribou.config/draw :raw-database)) {.... normal config map, secret stuff hidden} teague.core=> (c (caribou.config/draw :database))

org.tobereplaced.jdbcpool.JDBCPool{:datasource #<ComboPooledDataSource com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> z8kfsx8y1kb3rzjipb7x7|e040a13, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> z8kfsx8y1kb3rzjipb7x7|e040a13, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://secret-stuff?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=*****, password=**_***}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]>}

elided.core=> (keys (c (m/models))) (32 :view :perspective-lab-photos :status 1 2 34 :siphon :account 3 :model 4 5 37 :lab-detail 6 :delete-me :site :enumeration :field 7 :domain 8 :filter 9 :author 10 11 43 :resize 12 :page :location 13 14 :locale 15 16 18 :connect 20 :perspective-detail 21 22 23 :i18n :role 26 :showcase-detail-title-slide :permission :element :showcase-detail 30 :asset) elided.core=> (c (m/init)) DEBUG :INVOKE_MODELS No models table yet! DEBUG :stacktrace >>> java.lang.IllegalArgumentException: No implementation of method: :text-value of protocol: #'caribou.db.adapter.protocol/DatabaseAdapter found for class: nil DEBUG :stacktrace |--clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:541) DEBUG :stacktrace |--caribou.db.adapter.protocol$eval2479$fn2495$G24662502.invoke(protocol.clj:3) DEBUG :stacktrace |--caribou.field$structure_read.invoke(field.clj:178) DEBUG :stacktrace |--clojure.lang.AFn.applyToHelper(AFn.java:161) DEBUG :stacktrace |--clojure.lang.AFn.applyTo(AFn.java:151) DEBUG :stacktrace |--clojure.core$apply.invoke(core.clj:619) DEBUG :stacktrace |--clojure.core$update_in.doInvoke(core.clj:5587) DEBUG :stacktrace |--clojure.lang.RestFn.invoke(RestFn.java:445) DEBUG :stacktrace |--caribou.model$invoke_model.invoke(model.clj:837) DEBUG :stacktrace |--clojure.core$map$fn__4207.invoke(core.clj:2487) DEBUG :stacktrace |--clojure.lang.LazySeq.sval(LazySeq.java:42) DEBUG :stacktrace |--clojure.lang.LazySeq.seq(LazySeq.java:60) DEBUG :stacktrace |--clojure.lang.RT.seq(RT.java:484) DEBUG :stacktrace |--clojure.core$seq.invoke(core.clj:133) DEBUG :stacktrace |--clojure.core$dorun.invoke(core.clj:2780) DEBUG :stacktrace |--clojure.core$doall.invoke(core.clj:2796) DEBUG :stacktrace |--caribou.model$invoke_models.invoke(model.clj:868) DEBUG :stacktrace |--caribou.model$init$fn8960.invoke(model.clj:1104) DEBUG :stacktrace |--clojure.java.jdbc$with_connectionSTAR.invoke(jdbc.clj:302) DEBUG :stacktrace |--caribou.model$init.invoke(model.clj:1103) DEBUG :stacktrace |--teague.core$eval16996$fn16997.invoke(NO_SOURCE_FILE:1) DEBUG :stacktrace |--clojure.java.jdbc$with_connectionSTAR.invoke(jdbc.clj:302) DEBUG :stacktrace |--teague.core$eval16996.invoke(NO_SOURCE_FILE:1) DEBUG :stacktrace |--clojure.lang.Compiler.eval(Compiler.java:6619) DEBUG :stacktrace |--clojure.lang.Compiler.eval(Compiler.java:6582) DEBUG :stacktrace |--clojure.core$eval.invoke(core.clj:2852) DEBUG :stacktrace |--clojure.main$repl$read_eval_print6588$fn6591.invoke(main.clj:259) DEBUG :stacktrace |--clojure.main$repl$read_eval_print6588.invoke(main.clj:259) DEBUG :stacktrace |--clojure.main$repl$fn6597.invoke(main.clj:277) DEBUG :stacktrace |--clojure.main$repl.doInvoke(main.clj:277) DEBUG :stacktrace |--clojure.lang.RestFn.invoke(RestFn.java:1096) DEBUG :stacktrace |--clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn16112.invoke(interruptible_eval.clj:56) DEBUG :stacktrace |--clojure.lang.AFn.applyToHelper(AFn.java:159) DEBUG :stacktrace |--clojure.lang.AFn.applyTo(AFn.java:151) DEBUG :stacktrace |--clojure.core$apply.invoke(core.clj:617) DEBUG :stacktrace |--clojure.core$with_bindingsSTAR.doInvoke(core.clj:1788) DEBUG :stacktrace |--clojure.lang.RestFn.invoke(RestFn.java:425) DEBUG :stacktrace |--clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:41) DEBUG :stacktrace |--clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn16153$fn16156.invoke(interruptible_eval.clj:171) DEBUG :stacktrace |--clojure.core$comp$fn4154.invoke(core.clj:2330) DEBUG :stacktrace |--clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn16146.invoke(interruptible_eval.clj:138) DEBUG :stacktrace |--clojure.lang.AFn.run(AFn.java:24) DEBUG :stacktrace |--java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) DEBUG :stacktrace |--java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) DEBUG :stacktrace |--java.lang.Thread.run(Thread.java:724) nil

noisesmith commented 10 years ago

It may be we just need to do the model/init on the :raw-database key if :database is not a hash-map. c.j.jdbc does not need it to be a hash-map, so we shouldn't either.

noisesmith commented 10 years ago

We are complecting the config as something that informs us about the remote resource, and something that drives the connection. Rather than untangle this, I added a check for a pool, as an explicitly differentiated connection resource as separate from the config to create one.