Datamapper freezes gtk #62
Comments
@Andrea: Have you tried running with any of the other DO drivers, like MySQL or PostgreSQL? I just wanted to try to isolate whether or not the issue is with DataMapper or with the database drivers. For now I’m going to assign this to dbussink, in case it is a driver problem, but if it turns out to be the same across other DB drivers, and the problem is in DM, then please assign it back to me. by Dan Kubb (dkubb) |
@dan: i’ve tried both mysql and postgres right now, same issue. If you want help troubleshooting I’m more than happy to lend you my time, just tell me what would be useful to try. by Andrea Dallera |
What exact Ruby version are you running? (patch level included). Are you able to backtrace where exactly it gobbling up cpu cycles? Like a ctrl^c that for example shows which method it’s in? If you have a small test case I could run to verify, that would be even better for debugging purposes. by Dirkjan Bussink |
I’m running ruby 1.8.6 patchlevel287. I’ve tried 1.8.6 and 1.8.7 p72 too, same issue. by Andrea Dallera |
I prepared this test case. It’s the simplest i could come up withrequire ’libglade2’ class Main def initialize() class Document
end Main.new by Andrea Dallera |
Just one other question, what DataMapper version are you running? Last gem release or the DM next branch? by Dirkjan Bussink |
I’m running the latest gem version (0.9.11) by Andrea Dallera |
@Drikjan: do you need me to run any other tests? I started today looking at the source, it would be really helpful if you could tell me: Thanks in advance and, as i said already, don’t hesitate to contact me if you need some other test cases. by Andrea Dallera |
Sorry, but I haven’t really been able to dive into this. Could you check whether this still happens if you install DO and DM from the next branch on github? DO does have something that runs in a thread, that’s a scavenger that closes idle connections if they have been in the pool for over one minute. Other than that there is no threading activity in DO / DM that I’m aware of. by Dirkjan Bussink |
I’ve installed DO and DM from source. There’s a little problem in DO’ s rakefiles: Dir[’tasks/*.rake’].each { |f| import f } doesn’t import gem.rake as the first file so GEM_SPEC is undefined for the other tasks, I brutally inserted import ’tasks/gem.rake’ before and it works. Now the problem is that dm-core needs do_sqlite3 (or do_mysql, or do_postgres) version 0.10 which i couldn’t find (Do they exist?). What can i do about that? Did you run the snippet i posted before? If yes, does it behave as i told? Anyway i think the problem is connected to what you said, because i tried measuring the time it takes to crash and it’s always really close to 60 secs. Also (if they’re actually broken, which i think is unlikely to be, maybe there’s something wrong about my machine) I’d be glad to fix the rakefiles (NOT with the hack i mentioned of course :-). If that’s the case, how can i send you a patch? by Andrea Dallera |
For DO you also need the do/next branch on github, that holds DO 0.10. I haven’t run the example myself but if it’s around 60 secs it could very well be related then. by Dirkjan Bussink |
Extlib::Polling has a scavenger with 60 secs interval, i thought the problem was there but after removing all threading from the module i still got the weird freeze after exactly 60 seconds. Anyway you can close this issue by me, i’m switching to AR. by Andrea Dallera |
I would recommend not closing this ticket if we can help it. It’s very likely that the DataObjects drivers will become the default database drivers for ActiveRecord at some point -- possibly sooner rather than later -- so this problem will continue to affect others if it is an actual bug in DO. The only case I would recommend closing this ticket is if it was only reproducible by the submitter, and/or we don’t have enough information to continue on our own. by Dan Kubb (dkubb) |
What platform are you running this on (Linux (+distro), FreeBSD (+version) etc)? I’m currently seeing a "library routine called out of sequence (DataObjects::SQLError)" error on my Macbook when trying to run this. It looks like there is some concurrency issue here, I wonder whether your bug is another manifestation of the same concurrency issue. by Dirkjan Bussink |
I’ve encountered this issue running ubuntu 9.04 , ubuntu 8.10 and debian 5.0.2. As i said in the first post everything goes fine under windows XP. by Andrea Dallera |
With ruby-gnome2-0.16.0 and dm-core-0.9.11 (and older) I did not have this problem. Upgrading to ruby-gnome2-0.19.0 caused this problem to appear with both dm-core-0.9.11 and dm-core-0.10.0. This is on a gentoo ~x86 system (updated 2-3 times a week). My test app is similar to Andrea’s (http://gist.github.com/156815). After reading this report I did confirm that my test app pegs one of the cores (quad core) at 100%, with the core changing about every minute. $ cat /proc/version Installed gtk+: [I] x11-libs/gtk+ by Roy Wright |
@roy: Can you also try this with the DataMapper In-Memory and/or the YAML adapters? If the problem persists, then it is something wrong in DataMapper, but if it goes away then we can be reasonably certain it is something in DataObjects. by Dan Kubb (dkubb) |
It took a little effort, but did get dm-c0re-0.9.11 to run the test code successfully using dm-yaml-adapter-0.7. Switching back to sqlite::memory still caused the test code to be unsuccessful. dm-core-0.10.0 (from http://gems.datamapper.org) does not support auto_migrate! so could not get it to work with the test code using the yaml adapter (get a "undefined method `auto_migrate!’ for DataMapper:Module (NoMethodError)" error message). Updated test code (using yaml adapter) at: http://gist.github.com/158985 by Roy Wright |
I’m not seeing a hang on OS X, but I do get the following error message: dm-core/lib/dm-core/adapters/data_objects_adapter.rb:167:in `execute_reader’: library routine called out of sequence (DataObjects::SQLError) Could you try using do_mysql and / or do_postgres? They seem to not have this issue for me on OS X. It could be that the hang on Linux is a different result of the same issue that shows up for me on OS X. I guess it’s related to sqlite3 not being thread safe and that that causes something to trip up somewhere. by Dirkjan Bussink |
Did a new install of postgresql-8.3 and using do_postgres-0.9.12 saw the same problem as with sqlite3 (for the record, do_sqlite3-0.9.12). That’s implying it’s data_object dependent instead of adapter dependent. I ran with the ruby -W flag and saved the log messages at http://gist.github.com/159170 (along with the diffs between the logs). $ ruby --version Complete toolchain info at: http://gist.github.com/159171 by Roy Wright |
Could you try with using both DO’s next branch and DM’s next branch? You can clone them from github and switch to the branch and then install it as a gem. I would like to confirm that upgrading to next still exposes the issue. I find it weird that it doesn’t show up on OS X though, so i probably need to try this in a virtual machine. by Dirkjan Bussink |
BTW, what exact sqlite3 version are you running? by Dirkjan Bussink |
I’ll give the next branches a try. I’m also trying to install a recent bug fix release to ruby-gnome2 (0.19.1). I’m running sqlite-3.6.16 compiled with doc, tcl, and threadsafe options, but not with debug or soundex options. Thank you. by Roy Wright |
Got a response from Kou on the ruby-gnome2 mailing list:
by Roy Wright |
I believe I’ve run into the same underlying problem as well, albeit from a different angle -- sinatra & rack. (Thanks to dbussink for referring me to this thread.) I recently (re)wrote a ::Rack::Session::DataMapper module. When I was testing it, I noticed that every time I exited Sinatra (with ^C), it would "hang" waiting for a (mongrel) worker thread to release. The first worker thread, to be precise. When I disabled the module, it would exit fine. In Sinatra w/ Mongrel, each request spawns a new Thread, and since my Sinatra app didn’t do any DB accesses before my Rack module was invoked (beyond logging and adapter setup), DataMapper’s first real invocation was from within a short-lived Mongrel handler thread. I haven’t looked at dm-core yet, but I theorize that the intializing thread (Thread.current) stores some shared objects that get used outside the Thread’s context, thus bumping their reference counts. That worker thread then delays exit until its objects are released; conceivably those objects are either referenced by the Main thread (which upon ^C is waiting for the worker Thread to exit), or by another worker Thread that already died (potentially suggesting a lost refcount decrement?). Either way, both threads end up waiting for the other to exit, thus the hang. If I’m not far off the mark, the solution may be as simple as forcing any lazy initialization stuff to occur inside ::DataMapper.setup(). Gist with Rack plugin, small Sinatra app and related stuff: http://gist.github.com/164587 FWIW, this repros on Ruby 1.8.6 (OSX) & 1.8.7 (linux), Sinatra 0.9.2 && 0.10.1, dm-core 0.9.11 and dm-core.git (latest). by Jordan Ritter |
WRT my issue, looks like this is due to ::Extlib::Pooling.scavenger, which creates a new thread if it hasn’t been already. Since the hang only seems to happen to DO-derived adapters (:in_memory doesn’t seem to suffer), I simply added the scavenger call to DataObjectsAdapter#initialize - called through ::DataMapper.setup() - thereby eliminating the hang. It’s not immediately obvious to me that this fixes the GTK issue, but it might. 1-liner fix: http://github.com/jpr5/dm-core/commit/3379acf9ad12a154eabb9fcd3148a09f6fbc1a55 by Jordan Ritter |
Just tried the ::Extlib::Pooling.scavenger change on dm-core-0.9.11 and it did not resolve the gtk problem. by Roy Wright |
Is this still a problem, or is it safe to close this ticket? I see no activity or discussion for almost 9 or 10 months now. by Dan Kubb (dkubb) |
The issue’s been resolved, I think this is safe to close. by Andrea Dallera |
Someone reported that this ticket has not been resolved on IRC this afternoon: CathalMagus Hopefully this person will respond to this ticket so that more information can be gathered from them, and when this bug is resolved they can confirm it. by Dan Kubb (dkubb) |
It was I who mentioned this on IRC. I’m happy to run through various tests to help resolve this. Andrea didn’t mention which specific change "resolved" the issue for him. Perhaps the interaction on the libgnome2-ruby side has been fixed (I’m using 0.17.0~rc2 which is not the most up-to-date). by CathalMagus |
The issue was fixed on the ruby/gnome2 side, in version 0.19.2. If you update to a new version you won’t be experiencing the problem anymore. On the side, the problem was caused by a lock here http://github.com/datamapper/extlib/blob/master/lib/extlib/pooling.rb so maybe it should be useful to check that for thread safety. by Andrea Dallera |
Thanks Andrea, I upgraded to ruby-gnome2 0.19.3 and the issue is indeed resolved there. (I can also confirm that it was still present in version 0.19.0, which my new distro came with). by CathalMagus |
While the freeze behaviour is fixed with ruby-gnome2 0.19.3, the rogue CPU usage seems to be a problem still. My ruby-gnome2 app, Palatina, loads data from DataMapper and then sits there displaying it in a list. I’m using Anyone on a Debian-like system can install Palatina from my repository to test the issue. Much easier, I’ve updated Andreas’ simplest script which shows the problem and attached it as simplest.rb - it demonstrates the problem at around 60 seconds. by CathalMagus |
I'm using datamapper for persistence in this (http://github.com/Bolthar/rubydraulica/tree/master) application. The starts up smoothly then, after a couple of minutes after Datamapper.setup is been called, the ui freezes and the process' cpu % goes up to 100% (or 50% in dual core systems, 25% on quad). That means that the widgets don't get updated anymore, if i try to resize the window it doesn't get repainted, i can't focus on anything, the only fix is to kill the process and start it over again.
This actually happens only under unix, i've tried the same configuration (ruby 1.8.6, ruby-gnome 0.16) under both windows XP and ubuntu linux 9.04 and under windows everything works fine.
Created by Andrea Dallera - 2009-07-10 18:54:03 UTC
Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/966
The text was updated successfully, but these errors were encountered: