untangled

NEW CHANNEL: #fulcro
cjmurphy 2016-07-12T06:37:34.002062Z

I am trying to run todomvc against a :dev datomic database rather than how it ships (:free or :mem), but getting this error:

user=> 16-07-12 06:34:36 chris-XPS-L521X ERROR [untangled.server.impl.components.handler:72] - Parser error:
 {:status 500,
 :body
 {:type "class java.lang.Exception",
  :message
  "processing rule: (q__26671 ?e), message: Unable to find data source: $__in__2 in: ($ $__in__2)"}}

cjmurphy 2016-07-12T06:47:58.002065Z

The transactor is running, and "datomic:<dev://localhost:4334/todo>" is under /usr/local/etc/todomvc.edn's :url key.

2016-07-12T16:49:36.002066Z

@tony.kay @currentoor @therabidbanana pushed the change we were talking about yesterday to untangled-datomic. see https://github.com/untangled-web/untangled-datomic/commit/d6aac56485e09559a556e15b2c57964801bfe297. basically a wrapper for a transaction vector where you can specify a function to call after the schema migration completes successfully. that function takes the db connection so you can migrate the data

2016-07-12T16:50:09.002067Z

didn’t want to put the connection directly in the transaction function since it would be bad to call d/transact during the migration, which itself would be calling d/transact...

currentoor 2016-07-12T16:51:10.002069Z

@ethangracer: awesome!

2016-07-12T16:52:23.002070Z

Should we expect these functions to be executed multiple times? Seems like it's possible they could be?

currentoor 2016-07-12T16:53:24.002071Z

@therabidbanana: they have side effects right? So they shouldn't be called multiple times right?

2016-07-12T16:53:53.002072Z

no, in production the function should be called exactly once

2016-07-12T16:53:56.002073Z

when the migration is performed

2016-07-12T16:54:17.002074Z

if you’re in a dev environment on an in-memory database it’ll be called every time, of course

2016-07-12T16:54:40.002075Z

but the idea is when a migration happens you might want to port data just that one time, to match the new migration

2016-07-12T16:54:44.002076Z

e.g. renaming an attribute on all existing entities

currentoor 2016-07-12T16:58:03.002078Z

@ethangracer: if I have only data to migrate, so no schema changes will an empty transaction vector work?

currentoor 2016-07-12T16:58:18.002079Z

seems like it should but just making sure

2016-07-12T16:58:27.002080Z

wouldn’t that just be a standard transaction?

2016-07-12T16:58:41.002081Z

Well, I guess my point is that I was trying to read through this code before and I couldn't work out how they're prevented from running multiple times, other than conformity just being idempotent.

2016-07-12T16:59:02.002082Z

We don't use in-memory in dev mode much and I still see the logs for every single migration conforming

2016-07-12T16:59:08.002083Z

Every time I boot

2016-07-12T17:00:15.002084Z

Maybe that's just a misconfiguration on our side?

2016-07-12T17:00:19.002085Z

interesting. that would be a question for @adambros or @tony.kay — I think the system keeps track of which migrations have applied, but I’m not sure of the internals

2016-07-12T17:00:33.002086Z

it may log even though it does nothing

2016-07-12T17:00:58.002087Z

what I do know is that we have an app on production servers now and when we apply the migrations it’s not botching the data

2016-07-12T17:01:10.002088Z

🙂

tony.kay 2016-07-12T17:21:56.002089Z

Each migration is checked. We're using conformity, and it stores the applied migrations in the db so it knows what to re-apply.

tony.kay 2016-07-12T17:22:13.002090Z

I think our code does output which ones are being looked at so you can debug ordering issues and such

tony.kay 2016-07-12T17:22:30.002091Z

and it always looks at all of them...conformity decides if they get applied

tony.kay 2016-07-12T17:22:40.002092Z

we could have better output, I guess (e.g. ALREADY APPLIED)

2016-07-12T17:26:21.002093Z

I guess I don't see the part where conformity gets asked if it should run the after function for this new feature, if it is always checking all migrations, unless maybe ensure-conforms raises an error? https://github.com/untangled-web/untangled-datomic/commit/d6aac56485e09559a556e15b2c57964801bfe297#diff-e89eff854d20e40f1cd602547aafc92fR252

2016-07-12T17:26:45.002094Z

But if it was raising an error it'd be showing migration failures in our logs, I'd think

2016-07-12T17:31:58.002095Z

ah, good question

2016-07-12T18:46:42.002096Z

@therabidbanana: I agree

2016-07-12T18:47:02.002097Z

so, I think there needs to be a check if the database already conforms before running the migration

2016-07-12T18:47:27.002098Z

right now it’s happening after

tony.kay 2016-07-12T18:47:54.002099Z

we want the check after as a simple sanity check

tony.kay 2016-07-12T18:48:05.002100Z

but checking before so we know when to run data migration is needed

2016-07-12T18:48:11.002101Z

right, so both

tony.kay 2016-07-12T18:48:15.002102Z

right

2016-07-12T18:48:16.002103Z

ok, working on a patch

tony.kay 2016-07-12T18:48:41.002105Z

for that matter, you can then skip the ensure-conforms, since it probably starts with a short-circuit using conforms-to 🙂

2016-07-12T18:50:11.002106Z

and run the transactions ourselves? ensure-conforms is currently executing the migrations

tony.kay 2016-07-12T18:50:36.002107Z

right, but no need to call it if we're already calling conforms-to? and that returns false, correct?

2016-07-12T18:51:02.002108Z

yes, no need to call ensure-conforms, but we do have to call d/transact on each tx in the migration

tony.kay 2016-07-12T18:51:37.002109Z

oh right. thx

tony.kay 2016-07-12T18:51:42.002110Z

I trust you've got it 🙂

2016-07-12T20:35:23.002111Z

@therabidbanana great catch on the conformity, thanks for the code review!

👍 1
2016-07-12T20:35:25.002112Z

patch is pushed

tony.kay 2016-07-12T20:35:41.002113Z

confidence? Tested well?

2016-07-12T20:35:55.002114Z

hard to test well because it’s such an integration test with datomic

tony.kay 2016-07-12T20:36:09.002115Z

oh, you guys are prob using snapshots...work with it for a few days and let me know. I'll push a release once we know it is solid

tony.kay 2016-07-12T20:36:19.002116Z

you want me to push a snapshot to clojars?

2016-07-12T20:36:58.002117Z

let me play with it for the rest of the day, and try applying a migration to QA first

2016-07-12T20:37:07.002118Z

I do think it’s solid though

tony.kay 2016-07-12T20:37:27.002120Z

oh, well, I pushed a snapshot to clojars anyway...no guarantees on snapshots 🙂

😰 1
2016-07-12T20:39:46.002121Z

@ethangracer: glad I could help - especially since I know it won't be very long before we need this ourselves.

juno 2016-07-12T22:59:09.002122Z

Hello. I’m trying out untangled-websocket and I hit a little bit of an issue. In https://github.com/untangled-web/untangled-websockets/blob/master/src/untangled/websockets/networking.cljs at line 98. The callback function utilizes the deref global-error-callback but this function is passed in at client creation. Here is an error message when server returns an exception to the client. `No protocol method IDeref.-deref defined for type function: function (status,error){ return null; }`. For the client initialization. :networking (wn/make-channel-client "/chsk" :global-error-callback (fn [status error] nil)) Thank you.

2016-07-12T23:51:04.002124Z

how do I run untangled-client tests after checking out the repo?

2016-07-12T23:59:43.002125Z

I did

npm install; lein doo chrome test
I get a window that pops up that just says "chrome ready"