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

Custom slick thread pool, plus some async db cleanup #424

Merged
merged 2 commits into from
Feb 9, 2016

Conversation

kshakir
Copy link
Contributor

@kshakir kshakir commented Feb 5, 2016

No description provided.

@kshakir
Copy link
Contributor Author

kshakir commented Feb 5, 2016

The wheel chooseth @scottfrazer and @mcovarr, but happy for anyone else to take a look. Am leaving it as two commits as the first has the more important change, and the second is verbose cleanup.

// Update the database state:
val newBackendInfo = JesCallBackendInfo(Option(JesId(runId)), Option(JesStatus(currentStatus.toString)))
globalDataAccess.updateExecutionBackendInfo(workflowId, BackendCallKey(call, pipeline.key.index), newBackendInfo)
globalDataAccess.updateExecutionBackendInfo(
workflowId, BackendCallKey(call, pipeline.key.index), newBackendInfo)(ExecutionContext.global)
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember discussing this at the time it was written though it seems we kinda forgot to come back and clean it up. 😦

Copy link
Contributor

Choose a reason for hiding this comment

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

This will almost certainly run afoul of the incoming intel changes, but that makes it @mcovarr's problem :)

Copy link
Contributor

Choose a reason for hiding this comment

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

oh definitely it's already conflicting...

@mcovarr
Copy link
Contributor

mcovarr commented Feb 5, 2016

I'm certainly not a fan of littering a code base with FIXMEs but in this case I do think it's warranted in that one spot (you know where I mean 😄)


object DataAccess {
val globalDataAccess: DataAccess = new slick.SlickDataAccess()
}

trait DataAccess {
trait DataAccess extends AutoCloseable {
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't really seen anyone use this in scala, presumably just because it's a new-ish construct. I'm not saying this to poo poo it (it seems like a good idea), but more just to ensure we understand how it's actually working here. Is this something you've seen other slick stuff doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have not seen other slick code using this, but then again-- I haven't seen most typesafe code (slick, spray, akka, etc.) tidying up. Usually one has to go digging deep into the test code / google groups for finding instructions on how to cleanly shutdown.

What happened here was that I was wiring in the ExecutionContexts, when I realized I already made SlickDataAccess extend AutoCloseable back in PRs #371 / #403. The change was made such that when the liquibase/slick comparison finished, the both databases would be .autoClosed using better.files' ARM.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah ARM & Scala has been a weird thing for a while now :)

As long as you're reasonably sure that it's doing what you think it's doing (or at least not doing anything unfriendly) I'm all for it - as I said, on paper it seems like a good idea. I was just a bit leery about it being fairly unvetted in the scala/slick context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Man I'm so confused :) I've never seen an AutoCloseable before (I'm guessing it's this). I read the API but I guess I'm still not clear on why it was added!

@geoffjentry
Copy link
Contributor

It's entirely possible that this resolves all of the big bang problems, including the spray responsiveness. From what I saw yesterday the pain and suffering was primarily coming from the DB access.

@kshakir
Copy link
Contributor Author

kshakir commented Feb 5, 2016

Added a basic regression test that verifies our deadlock workaround.

@mcovarr
Copy link
Contributor

mcovarr commented Feb 5, 2016

👍 nice job getting this to work, though I really hope Slick 3.2.0 makes this unnecessary. 😄

@geoffjentry
Copy link
Contributor

At some point over the weekend I'll see if it seems to resolve the other issues we were seeing as well. If so I'll go ahead and close the ticket I have. I don't think we really need to bulkhead out anything other than the DB IO at the moment, will take a look.

@mcovarr mcovarr assigned scottfrazer and unassigned mcovarr Feb 6, 2016
@geoffjentry
Copy link
Contributor

@kshakir I want to tech talk on this a bit prior to merging. I think it's fine as-is but want to make sure we think through the nuance and/or logical next steps

@kshakir kshakir force-pushed the ks_custom_slick_thread_pool branch 4 times, most recently from ae3c19a to 779a225 Compare February 8, 2016 21:04
@geoffjentry
Copy link
Contributor

@kshakir I wonder if there's a way to put in a little check in all of our funcs here which verifies that the EC which comes in is the one that we're hoping it to be? As I mentioned at tech talk I always get sketched out at these implicit ECs.

Either way, 👍 from me

@scottfrazer
Copy link
Contributor

👍

@scottfrazer scottfrazer removed their assignment Feb 9, 2016
@kshakir kshakir force-pushed the ks_custom_slick_thread_pool branch 2 times, most recently from c193390 to 2fe3131 Compare February 9, 2016 16:37
Shutting down our custom slick thread pool when the database closes.
Added changelog item.
Added deadlock test.
Passing in the execution context used for flatmap'ing slick futures, and a) NOT using Slick's internal thread pool, and b) not just defaulting to the global execution context (...mostly).
- http://slick.typesafe.com/doc/3.1.0/gettingstarted.html#quick-introduction
- https://github.com/alexandru/scala-best-practices/blob/master/sections/4-concurrency-parallelism.md#411-must-not-hardcode-the-thread-pool--execution-context
- https://groups.google.com/d/msg/scalaquery/5i543a9Vkt0/7ENpRx_35sYJ
kshakir added a commit that referenced this pull request Feb 9, 2016
Custom slick thread pool, plus some async db cleanup
@kshakir kshakir merged commit ac75c80 into develop Feb 9, 2016
@kshakir kshakir deleted the ks_custom_slick_thread_pool branch February 9, 2016 16:53
Sign up for free to 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