Neo4j - rails console - can't wait on resource RWLock error - neo4j

Getting this error from the rails console:
a = Author.first
Neo4j::Server::CypherResponse::ResponseError: LockClient[12] can't wait on resource RWLock[SCHEMA(0), hash=1915081964] since => LockClient[12] <-[:HELD_BY]- RWLock[SCHEMA(0), hash=1915081964] <-[:WAITING_FOR]- LockClient[3] <-[:HELD_BY]- RWLock[SCHEMA(0), hash=1915081964]
Server is up and runing, able to execute any query from the database console, or from the database browser interface.
What is wrong here?

After looking a bit I realized/remembered that there are some changes on master which deal with this:
https://github.com/neo4jrb/neo4j/issues/732
Try changing your Gemfile to this:
gem 'neo4j', github: 'neo4jrb/neo4j'
gem 'neo4j-core', github: 'neo4jrb/neo4j-core'
We're planning on cutting a release candidate next week, so if this works for you you won't need to run off master for long

Related

Custom busy handler for Rails SQLite3

I have a Rails/SQLite3 setup which is getting exceptions
ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked):
Now I understand that SQLite3 cannot do parallel writes, I'd be happy if they were blocked until the other write was finished, so done serially, rather than raising. This is something to do with default SQLite3 handler in C falling foul of Ruby's GIL, apparently. The fix, according to this post, is to install one's own "busy handler" for the SQLite3 connection, and I have this code in a Rails initializer
# config/initializers/sqlite3.rb
if ActiveRecord::Base.connection.adapter_name == 'SQLite' then
if raw_connection = ActiveRecord::Base.connection.raw_connection then
puts 'installing busy handler'
raw_connection.busy_handler do |count|
puts 'QUACK'
end
puts 'done'
else
raise RuntimeError 'no DB raw connection!'
end
end
On starting Rails (Puma in the console) I get the expected
installing busy handler
done
but on running parallel requests I get the exception with no QUACK, i.e., it seems that my handler has not been called. Is this a misunderstanding of the scope of initializers? Is there a "correct" way to get this handler installed?
(Obviously the real handler will not just say QUACK, but I find that my "real" handler has no effect so replace it by a debugging version.)

Heroku/Memcache/Rack::Cache Stats

I am trying to wrap my brain around Rack::Cache, Rails 3.2, Memcache, and Heroku. I think I've got it all working together, as outlined here: http://myownpirateradio.com/2012/01/01/getting-heroku-cedar-and-rails-3-1-asset-pipeline-to-play-nicely-together/
All that said, I am unsure if Memcached is actually doing what it should. Is there any way to get stats on Memcached or to see if a request was cached by Memcached? I put the current time on a page, and can see that it is getting cached (headers look good too), but how do I know it is all working with Memcached, as opposed to the file store?
Thanks.
You can get stats on memcached by doing:
$ heroku run console
Running console attached to terminal... up, run.1
Loading production environment (Rails 3.1.3)
irb(main):001:0> Rails.cache.stats
Dalli/SASL authenticating as app590983%40heroku.com
Dalli/SASL: Authenticated
=> {"mc5.ec2.northscale.net:11211"=>{"evictions"=>"0", "curr_items"=>"627",
"total_items"=>"1257", "bytes"=>"2294318", "reclaimed"=>"0",
"engine_maxbytes"=>"5242880", "bucket_conns"=>"2", "pid"=>"319",
"uptime"=>"6710022", "time"=>"1330731177", "version"=>"1.4.4_207_g19c6b9e",
"libevent"=>"1.4.11-stable", "pointer_size"=>"64",
"rusage_user"=>"34354.590000", "rusage_system"=>"31381.520000",
"daemon_connections"=>"10", "curr_connections"=>"1211",
"total_connections"=>"14127919", "connection_structures"=>"1764",
"cmd_get"=>"9476", "cmd_set"=>"1257", "cmd_flush"=>"0", "auth_cmds"=>"24",
"auth_errors"=>"0", "get_hits"=>"8093", "get_misses"=>"1383",
"delete_misses"=>"0", "delete_hits"=>"0", "incr_misses"=>"0",
"incr_hits"=>"0", "decr_misses"=>"0", "decr_hits"=>"0", "cas_misses"=>"0",
"cas_hits"=>"0", "cas_badval"=>"0", "bytes_read"=>"21983909",
"bytes_written"=>"85267718", "limit_maxbytes"=>"67108864",
"rejected_conns"=>"0", "threads"=>"4", "conn_yields"=>"0"}}
PS: I think you might need to be using the Dalli gem for this to work, but that is the recommended client anyway.
You can also run Rails.cache.class to see which backend is Rails using.

what maxmind geoip ruby wrapper is up2date and usable? ( for the commercial library )

Im trying to get below github repo in my app
https://github.com/mtodd/geoip
Ive tried adding it like
gem "geoip", :git => "git://github.com/mtodd/geoip.git"
Error =
Could not find gem 'geoip (>= 0) ruby' in git://github.com/mtodd/geoip.git (at master).
Source does not contain any versions of 'geoip (>= 0) ruby'
Is there are ruby gem wrapper for GeoIP that is compatible with the LATEST GEOIP?
Ive searched very long for one, the one above seems to be sort off compatible with 1.4.7 and higher but I can't get it installed, any other suggestion? Thx !
I have this in my Gemfile:
gem "geoip-c", '~> 0.7.1', :git => "git://github.com/mtodd/geoip.git"
As far as I know, it's totally compatible.
I know this was posted a few years ago, but I recently had trouble finding a good up-to-date gem for this. What I found was Geoip2 by YotpoLtd.
In my Gemfile
gem 'geoip2'
Setting/Configuring
Geoip2.configure do |conf|
# Mandatory
conf.license_key = 'Your MaxMind License Key'
conf.user_id = 'Your MaxMind User Id'
# Optional
conf.host = 'geoip.maxmind.com' # Or any host that you would like to work with
conf.base_path = '/geoip/v2.0' # Or any other version of this API
conf.parallel_requests = 5 # Or any other amount of parallel requests that you would like to use
end
Using
data = Geoip2.omni('0.0.0.0') #this call is synchronous
*note: I believe you can replace 'omni' with the name of the product tier: city, country, etc
Errors
If there is an error, the returned hash will have an error object, so simply check for its existence
if data.error
# error handling
else #still might want to check for data's existence ( if data )
#access object as you will
data.city.names.en
data.postal.code
end
For more information about the returned hash, see the MaxMind Web Services Documentation

youtube_it gem not working in Rails console or IRB

I installed the youtube_it version(2.0.1) gem but I cannot seem to get it to work in the rails console or in irb. I follow all the steps shown here for establishing a client, but when I perfore the query:
client.videos_by(:query => "penguin")
I get
<YouTubeIt::Response::VideoSearch:0x101f1c460 #max_result_count=nil, #updated_at=nil, #offset=nil, #feed_id=nil, #videos=[], #total_result_count=nil>
I have tried it from inside my App's directory and out; with irb and rails console and I get the same thing every time. Any ideas would be greatly appreciated.
this is working for me, did you try whit the last version of the gem (2.1.3)?, I'm using this and works nice
irb(main):004:0> client = YouTubeIt::Client.new
=> #<YouTubeIt::Client:0x007fc5a0116a58>
irb(main):005:0> client.videos_by(:query => "penguin").videos.count
http://gdata.youtube.com/feeds/api/videos?max-results=25&q=penguin&start-index=1&v=2
=> 25
tell me if this works for you
cheers!

Use cache money only for a single model?

I want to use cache-money but I don't want to start automatically caching everything (I'm working with a large production app, terabytes of data etc). How do I use it for only the models that I specify? Right now I've got:
# initializers/cache_money.rb
require 'cache_money'
config = (cfg = YAML.load(IO.read(File.join(RAILS_ROOT, "config", "memcached.yml"))))[RAILS_ENV] || cfg["defaults"]
$memcache = MemCache.new(config)
$memcache.servers = config['servers']
$local = Cash::Local.new($memcache)
$lock = Cash::Lock.new($memcache)
$cache = Cash::Transactional.new($local, $lock)
and then in the model I want to cache with cache-money:
# my_model.rb
class MyModel < ActiveRecord::Base
is_cached :repository => $cache
# ...
end
But this doesn't work; the call to is_cached gives the following error: NoMethodError: undefined method `create' for Config:Module
Any ideas? Failing that, is there anywhere I can go for help with cache-money? I couldn't find a mailing list or anything.
I think this is a bug in the cache_money code.
There are forks available on github that fix this bug, eg:
http://github.com/quake/cache-money
The fix can be seen with this commit:
http://github.com/quake/cache-money/commit/54c3d12789f31f2904d1fe85c102d7dbe5829590
I've just experienced the same problem trying to deploy an application. Running on my development machine it was fine, but it failed with this error on the production machine.
Apart from the architecture (OSX vs CentOS) the only difference i could see was that the ruby versions were different (1.8.6 p114 vs 1.8.6 p0). After upgrading the server to the latest 1.8 version (1.8.7 p160) this error went away.

Resources