I have an app setup with Rails 3.1, Mongo 1.4.0, Mongoid 2.2.4.
What I am experiencing is this:
Mongo::ConnectionFailure: Failed to connect to a master node at localhost:27017
I've had this problem before, but it went away on a computer restart... this time it does not.
I don't understand, I didn't do anything. I just put my computer in sleep mode, went home and woke it up, then there it was.
Here is the output of sudo mongod
Fri Nov 25 21:47:14 [initandlisten] MongoDB starting : pid=1963 port=27017 dbpath=/data/db/ 64-bit host=xxx.local
Fri Nov 25 21:47:14 [initandlisten] db version v2.0.0, pdfile version 4.5
Fri Nov 25 21:47:14 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027caa406222
Fri Nov 25 21:47:14 [initandlisten] build info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Fri Nov 25 21:47:14 [initandlisten] options: {}
Fri Nov 25 21:47:14 [initandlisten] journal dir=/data/db/journal
Fri Nov 25 21:47:14 [initandlisten] recover : no journal files present, no recovery needed
Fri Nov 25 21:47:15 [websvr] admin web console waiting for connections on port 28017
Fri Nov 25 21:47:15 [initandlisten] waiting for connections on port 27017
And I am able to connect with mongoin terminal.
After 2 hours of Googling I hope the competence of SOs community are able to figure this out.
Please, if you need more information about my app-setup just ask.
Thanks!
What you see is that the connection times out... that happens either after a long period of inactivity, or if you put your computer to sleep.
You can change / increase the timeout value, but this way you can't get rid of the connection timing out eventually.
Some MongoDB drivers allow to set :timeout => false , but Mongoid seems to still have problems with that
(see last 3 links in the list)
Hope this helps.
See also:
Mongodb server goes down, how to prevent Rails app from timing out?
MongoDB: What is connection pooling and timeout?
https://github.com/mongodb/mongo-ruby-driver
How can I query mongodb using mongoid/rails without timing out?
http://groups.google.com/group/mongoid/browse_thread/thread/b5c94e7047b42f8a
https://github.com/mongoid/mongoid/issues/455
Try to change localhost to 127.0.0.1!
Related
I cannot figure this out. Hope I can get some help
I have a hobby tier in Heroku running django. To this I would like to attach a Redis service. However, I would like to use the recent rejson (redislabs/rejson:latest) docker image (instead of redistogo or heroku-redis)because it has json support. This works great on my local env. I was able to push the docker image into the container registry and actually start the redis server
2021-07-23T00:14:48.576294+00:00 app[worker.1]: 3:M 23 Jul 2021 00:14:48.576 # Current maximum open files is 10000. maxclients has been reduced to 9968 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
2021-07-23T00:14:48.577054+00:00 app[worker.1]: 3:M 23 Jul 2021 00:14:48.577 * Running mode=standalone, port=6379.
2021-07-23T00:14:48.577124+00:00 app[worker.1]: 3:M 23 Jul 2021 00:14:48.577 # Server initialized
2021-07-23T00:14:48.577184+00:00 app[worker.1]: 3:M 23 Jul 2021 00:14:48.577 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2021-07-23T00:14:48.577671+00:00 app[worker.1]: 3:M 23 Jul 2021 00:14:48.577 # <ReJSON> JSON data type for Redis v1.0.7 [encver 0]
2021-07-23T00:14:48.577789+00:00 app[worker.1]: 3:M 23 Jul 2021 00:14:48.577 * Module 'ReJSON' loaded from /usr/lib/redis/modules/rejson.so
2021-07-23T00:14:48.578232+00:00 app[worker.1]: 3:M 23 Jul 2021 00:14:48.578 * Ready to accept connections
Unfortunately, django is unable to connect to it
ConnectionError: Error -2 connecting to redis://localhost:6379. Name or service not known
There are no ENV variable exposed, so am unable to set any (I mean I can set them, but doubt if they will be relevant)
I did experiment with installing redistogo add on and am able to connect to it (this required setting the connection based on the REDIS_URL env variable that gets exposed when redistogo is added)
At my wits end...any help appreciated...I guess the question really boils do to:
Recently, if I do 2-3 builds in succession on Jenkins, my Karma task fails for the following reason:
Running "karma:jenkins" (karma) task
[32m13 02 2017 16:46:00.876:INFO [karma]: [39mKarma v1.3.0 server started at http://localhost:9018/
[32m13 02 2017 16:46:00.878:INFO [launcher]: [39mLaunching browser PhantomJS with unlimited concurrency
[32m13 02 2017 16:46:00.885:INFO [launcher]: [39mStarting browser PhantomJS
[32m13 02 2017 16:46:01.345:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: [39mConnected on socket /#lF481tq-G7blX6hpAAAA with id 85942733
[33m13 02 2017 16:46:11.346:WARN [PhantomJS 2.1.1 (Linux 0.0.0)]: [39mDisconnected (1 times), because no message in 10000 ms.
This is happening for me for both Karma: 1.3.0 AND 1.4.1. Same PhantomJS version on both builds. NPM version: 3.10.10
I've tried specifying the host, the address, and extending the timeout. I'm out of solutions, unfortunately.
I have an embedded application running NodeMCU that is not connected to a console as the UART has been repurposed to obtain serial data from an attached device.
During testing the application ran for about 15 hours then rebooted 5 times in a row before "settling" and continuing to run correctly.
Is it possible to log to a file a traceback of what caused the reboots? I am assuming some kind of PANIC error caused the reboot. I don't think it is a memory issue as the application reports the heap size (via http to a local server) every 30 seconds. Here is a log extract:
Wed May 18 00:46:37 2016 -> '{"s":"1782","i":"1afe34d26348", "d":"heap=12408
Wed May 18 00:47:08 2016 -> '{"s":"1783","i":"1afe34d26348", "d":"heap=12408
Wed May 18 00:47:39 2016 -> '{"s":"1784","i":"1afe34d26348", "d":"heap=12408
Wed May 18 00:48:19 2016 -> '{"s":"1785","i":"1afe34d26348", "d":"heap=11432
Wed May 18 00:50:06 2016 -> '{"s":"0","i":"1afe34d26348", "d":"heap=14560
Wed May 18 00:51:25 2016 -> '{"s":"0","i":"1afe34d26348", "d":"heap=14584
Wed May 18 00:52:45 2016 -> '{"s":"0","i":"1afe34d26348", "d":"heap=14560
Wed May 18 00:54:04 2016 -> '{"s":"0","i":"1afe34d26348", "d":"heap=14584
Wed May 18 00:55:24 2016 -> '{"s":"0","i":"1afe34d26348", "d":"heap=14608
Wed May 18 00:55:55 2016 -> '{"s":"1","i":"1afe34d26348", "d":"heap=12608
Wed May 18 00:56:26 2016 -> '{"s":"2","i":"1afe34d26348", "d":"heap=12600
Wed May 18 00:56:56 2016 -> '{"s":"3","i":"1afe34d26348", "d":"heap=12624
Wed May 18 00:57:27 2016 -> '{"s":"4","i":"1afe34d26348", "d":"heap=12600
I the above log "s" is a sequential counter that is reset to 0 when the device reboots, and "d" is the heap size (you can ignore the "i" entry, it is just the MAC address of the device that is sending the data).
xpcall won't work in the case of a PANIC device reset.
I tried logging node.bootreason() to a file on reboot, but it doesn't contain a traceback to where the error occurred.
Is there some method for troubleshooting nodemcu applications that aren't connected to a console?
I have copied over all TokuMX 1.4 data files to a fresh installed TokuMX 1.5 server, but launching the server fails with:
Fri Aug 1 09:51:04.633 [initandlisten] TokuMX starting : pid=42210 port=27017 dbpath=/data/db 64-bit host=beagle.massive-insights.com
Fri Aug 1 09:51:04.633 [initandlisten] TokuMX mongod server v1.5.0-mongodb-2.4.10, using TokuKV rev 479eed747982601fa52e4c4e4b9b4be18f58d3c1
Fri Aug 1 09:51:04.633 [initandlisten] git version: 3c686d0b09d6dfb9fd54da440247d3075fcfd0ac
Fri Aug 1 09:51:04.633 [initandlisten] build info: Linux a5f9a8a9a9af 3.11.0-20-generic #35-Ubuntu SMP Fri May 2 21:32:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux BOOST_LIB_VERSION=1_49
Fri Aug 1 09:51:04.633 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/data/db", logFlushPeriod: 300, logappend: "true", logpath: "/var/log/mongodb/mongodb.log", maxConns: 20000 }
Fri Aug 1 09:51:04.634 [initandlisten] [tokumx] startup
Cannot upgrade TokuDB version 25 database. Previous improper shutdown detected.
Fri Aug 1 09:51:04.661 [initandlisten] Assertion: 16767:Unhandled ydb error: -100011
0xb3b123 0x80c91b 0x8061f0 0x8069df 0x8071fc 0x749e7a 0x74a558 0x735caa 0x7f5a97b5ceed 0x746e79
/usr/local/bin/mongod(_ZN5mongo15printStackTraceERSo+0x23) [0xb3b123]
/usr/local/bin/mongod(_ZN5mongo7storage21MsgAssertionExceptionC2EiRKSs+0x9b) [0x80c91b]
/usr/local/bin/mongod(_ZN5mongo7storage16handle_ydb_errorEi+0x390) [0x8061f0]
/usr/local/bin/mongod(_ZN5mongo7storage22handle_ydb_error_fatalEi+0xf) [0x8069df]
/usr/local/bin/mongod(_ZN5mongo7storage7startupEPNS_16TxnCompleteHooksEPNS0_14UpdateCallbackE+0x5bc) [0x8071fc]
/usr/local/bin/mongod(_ZN5mongo14_initAndListenEi+0x34a) [0x749e7a]
/usr/local/bin/mongod(_ZN5mongo13initAndListenEi+0x18) [0x74a558]
/usr/local/bin/mongod(main+0x29a) [0x735caa]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd) [0x7f5a97b5ceed]
/usr/local/bin/mongod() [0x746e79]
Fri Aug 1 09:51:04.670 [initandlisten] fatal error 16767: Unhandled ydb error: -100011
Fri Aug 1 09:51:04.670 [initandlisten] 16767 Unhandled ydb error: -100011
Fri Aug 1 09:51:04.670 [initandlisten] Fatal Assertion 16767
0xb3b123 0x9e654c 0x806bc6 0x8071fc 0x749e7a 0x74a558 0x735caa 0x7f5a97b5ceed 0x746e79
/usr/local/bin/mongod(_ZN5mongo15printStackTraceERSo+0x23) [0xb3b123]
/usr/local/bin/mongod(_ZN5mongo13fassertFailedEi+0x4c) [0x9e654c]
/usr/local/bin/mongod(_ZN5mongo7storage22handle_ydb_error_fatalEi+0x1f6) [0x806bc6]
/usr/local/bin/mongod(_ZN5mongo7storage7startupEPNS_16TxnCompleteHooksEPNS0_14UpdateCallbackE+0x5bc) [0x8071fc]
/usr/local/bin/mongod(_ZN5mongo14_initAndListenEi+0x34a) [0x749e7a]
/usr/local/bin/mongod(_ZN5mongo13initAndListenEi+0x18) [0x74a558]
/usr/local/bin/mongod(main+0x29a) [0x735caa]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd) [0x7f5a97b5ceed]
/usr/local/bin/mongod() [0x746e79]
Fri Aug 1 09:51:04.677 [initandlisten]
How can I go about the migration path 1.4 to 1.5, and how to deal with that error above?
As the log file states, "Cannot upgrade TokuDB version 25 database. Previous improper shutdown detected."
TokuMX does not support upgrades (meaning the file format has changed) unless the files you are using from the prior version came from a cleanly shutdown TokuMX.
You need to cleanly shutdown your 1.4 server, then copy or re-use the data files with 1.5.
I created a library that would record events to MongoDB from my Rails application. I'm using version 1.4.0 of the mongo gem and Rails 3.0 w/Ruby 1.8.7. The relevant code is:
def new_event(collection, event)
#conn = Mongo::Connection.new("localhost", 27017, :pool_size => 5, :pool_timeout => 5)
#conn.db("event").collection(collection).insert(event)
#conn.close
end
This has worked fine for recording new events as they happen on the site. However, I also need to backfill the db with old events. So I'm doing running a script that basically does this:
SomeModel.find_each do |model|
Tracker.new.new_event("model_event", { ... info from model ... })
end
I'm trying to backfill something on the order of 50k events. As the script runs, I see this:
Tue Sep 27 23:45:20 [initandlisten] waiting for connections on port 27017
Tue Sep 27 23:46:20 [clientcursormon] mem (MB) res:12 virt:78 mapped:0
Tue Sep 27 23:48:49 [initandlisten] connection accepted from 127.0.0.1:51006 #1
Tue Sep 27 23:49:03 [conn1] remove event.application 103ms
Tue Sep 27 23:49:12 [conn1] remove event.listing 127ms
Tue Sep 27 23:49:20 [clientcursormon] mem (MB) res:37 virt:207 mapped:128
Tue Sep 27 23:51:44 [initandlisten] connection accepted from 127.0.0.1:48103 #2
Tue Sep 27 23:51:44 [conn2] end connection 127.0.0.1:48103
Tue Sep 27 23:51:44 [initandlisten] connection accepted from 127.0.0.1:48104 #3
Tue Sep 27 23:51:44 [conn3] end connection 127.0.0.1:48104
Tue Sep 27 23:51:44 [initandlisten] connection accepted from 127.0.0.1:48105 #4
Tue Sep 27 23:51:44 [conn4] end connection 127.0.0.1:48105
Tue Sep 27 23:51:44 [initandlisten] connection accepted from 127.0.0.1:48106 #5
Tue Sep 27 23:51:44 [conn5] end connection 127.0.0.1:48106
The ports (127.0.0.1:XXXXX) and (what I assume are) the Connection Pool #s keep incrementing, until eventually I get this exception from the ruby script:
Failed to connect to a master node at localhost:27017
/var/bundler/turtle/ruby/1.8/gems/mongo-1.4.0/lib/../lib/mongo/connection.rb:526:in `connect'
/var/bundler/turtle/ruby/1.8/gems/mongo-1.4.0/lib/../lib/mongo/connection.rb:688:in `setup'
/var/bundler/turtle/ruby/1.8/gems/mongo-1.4.0/lib/../lib/mongo/connection.rb:104:in `initialize'
Just found the solution. I needed to make the connection object a class variable so it was shared across all instances of the Tracker class.
##conn = Mongo::Connection.new("localhost", 27017, :pool_size => 5, :pool_timeout => 5)
def self.new_event(collection, event)
##conn.db("event").collection(collection).insert(event)
end