MongoMapper - Mongo::OperationFailure - Database command 'update' failed: BSON field 'update.multi' is an unknown field - ruby

I am getting Mongo::OperationFailure - Database command 'update' failed: BSON field 'update.multi' is an unknown field. error on MongoMapper set method.
eg:
Metadata.set({:cid => 123}, :brand => "b1")
REF: http://mongomapper.com/documentation/plugins/modifiers.html
I am using following environment:
- Ruby 2.2.0
- Rails 3.2.22
- Gem MongoMapper 0.14.0
- MongoDB 3.6.0
[EDIT]
I am also getting it on insert with error Mongo::OperationFailure: Database command 'insert' failed: BSON field 'insert.w' is an unknown field.
MongoMapper Query

Had the same exact error, was fighting for a while.
solved by using mongo 3.2 - inside of docker container, because wasn't able to start it localy...
something like this eventually worked for me
docker run -it -p 27017:27017 mongo:3.2 bash

I had the same problem, in my case the problem was on the connection:
logger = Logger.new(STDOUT)
mongo_connection = Mongo::Connection.new '127.0.0.1', 27017, logger: logger
The 'logger:' option was missing.

Related

puppet-mongodb module doesn't show Mongo shell errors in puppet-agent run

We use the voxpupuli/puppet-mongodb module to create and manage Mongo data bases and users.
As usual we add necessary data to manifests and Hiera and after that the module form a command which it runs on the client side during a puppet-agent run.
We can see the executing command from the puppet-agent debug logs for instance this command create a new DB with the name unixtest_db:
Executing: '/usr/bin/mongo unixtest_db2 --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); db.dummyData.insert({"created_by_puppet": 1})'
The problem is the module never report any errors occurred during the commands execution.
For example consider the next hiera code:
tele2_mongodb::mongodb_db:
'unixtest_db': # DB name
user : unixtest
password : >
ENC[PKCS7,....]
auth_mechanism : scram_sha_1
roles :
- dbOwner
As result we have the next command executing and results:
Executing: '/usr/bin/mongo unixtest_db2 --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); db.dummyData.insert({"created_by_puppet": 1})'
Notice: /Stage[main]/Tele2_mongodb/Mongodb::Db[unixtest_db]/Mongodb_database[unixtest_db]/ensure: created
Now we can connect to the DB with the user credential mentioned in hiera:
# mongo -u unixtest -p password unixtest_db
MongoDB shell version v5.0.9 connecting to: mongodb://127.0.0.1:27017/unixtest_db?
...
unixtesttst:PRIMARY>
Next we change the DB name in Hiera to all capital letters:
tele2_mongodb::mongodb_db:
'UNIXTEST_DB': # DB name
In puppet agent output we see identical:
Executing: '/usr/bin/mongo UNIXTEST_DB --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); db.dummyData.insert({"created_by_puppet": 1})'
Notice: /Stage[main]/Tele2_mongodb/Mongodb::Db[UNIXTEST_DB]/Mongodb_database[UNIXTEST_DB]/ensure: created
But the database is not created, it's not in the db.adminCommand('listDatabases') output (the 1st one with all small letters still exist).
And if we run the command manually on the OS console, we see the error message:
# /usr/bin/mongo UNIXTEST_DB --host 127.0.0.1:27017 --eval " load('/root/.mongorc.js'); db.dummyData.insert({"created_by_puppet": 1})"
MongoDB shell version v5.0.9
...
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 13297,
"errmsg" : "db already exists with different case already have: [unixtest_db] trying to create [UNIXTEST_DB]"
}
})
So my question is how to make the puppet also report errors if command execution failed instead of fake notification everything went smoothly.
I have the same problem for DB changes, users and passwords. If something went wrong we never know that from the puppet output.
Any ideas how to fix it?

Elasticsearch/Logstash Error: com.mysql.jdbc.Driver not loaded - can't locate mysql-connector-java-5.1.36-bin.jar on server

I'm trying to install the jdbc plugin for Logstash on a AWS EC2 server so I can query a MySQL database.
Logstash is working but I can't get the JDBC plugin to work. When I run Logstash I get this error:
Error: com.mysql.jdbc.Driver not loaded. Are you sure you've included
the correct jdbc driver in :jdbc_driver_library?
I tried installing the JDBC plugin based on this:
https://discuss.elastic.co/t/getting-started-with-jdbc-input-plugin/77162
The install looked like it worked:
[ec2-user# settings]$ sudo /usr/share/logstash/bin/logstash-plugin install logstash-input-jdbc
Validating logstash-input-jdbc
Installing logstash-input-jdbc
Installation successful
But when I try to find the .jar file for the mysql connector it does not seem to exist on the system:
[ec2-user# logstash]$ sudo find / -name "*connector-java*"
This is what my Logstash config file looks like:
input {
jdbc {
jdbc_driver_library => "mysql-connector-java-5.1.36-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://***:3306/website"
jdbc_user => "***"
jdbc_password => "***"
statement => "SELECT * from runtime_ProdFull WHERE `MfPN` LIKE 'KO8%'"
}
}
How do I identify the correct name for jdbc_driver_library and how do I find it's path so I can add it to my config?
Thanks,
Phil
SOLUTION:
I downloaded the latest platform independent version from https://dev.mysql.com/downloads/connector/j/ to my PC, unzipped the mysql-connector-java-8.0.15.jar file and uploaded to the EC2 server via WinSCP to /var/lib/logstash/.
Then changed the jdbc driver to:
jdbc_driver_library => "/var/lib/logstash/mysql-connector-java-8.0.15.jar"
You have to download JDBC driver by yourself. Go to this website and download appropriate driver for your database and then put it somewhere in your EC2. Then you just have to specify path to the downloaded driver in this field jdbc_driver_library and you're good to go.

W7 Logstash JRUBY Error

I am new to the entire ELK Stack, and I am trying to set up Logstash. I followed all of the instructions (unzipping, setting up config file, starting Logstash). My setup is Windows 7, and my java version is 1.8.0_51.
When I run the following command (pipeline.conf is my config file):
C:\Elastic\logstash-6.2.2\bin>logstash -f pipeline.conf
I am getting the following error:
[ERROR] 2018-03-15 12:30:05.101 [main] Logstash -
java.lang.IllegalStateException:
org.jruby.exceptions.RaiseException:
(LoadError) Could not load FFI Provider:
(NotImplementedError) FFI not available:
com.kenai.jffi.Foreign.getVersion()I
See http://jira.codehaus.org/browse/JRUBY-4583
Here is what my config file:
input {
stdin {
}
}
output {
stdout {
codec => rubydebug
}
}
Any help would be appreciated. http://jira.codehaus.org/browse/JRUBY-4583 doesn't seem like a valid site. I have tried my exact process on a different machine, and Logstash works. I have been trying to look for a solution for about 2 days now. HELP PLS
Issue Resolved on the Elastic Discussion site:
https://discuss.elastic.co/t/windows-7-logstash-jruby-error/124152

I cannot create new issue through with REST API

I'm troubled with redmine.
When I create new issue with Rest API(from Microsoft Excel), Internal Error 500 happened.
Seeing from production.log, "NoMethodError" is happened (see below message)
Started POST "/redmine/issues.xml?key=XXXXXXX" for XX.XX.XX.XXX at 2016-05-30 14:44:10 +0900
Processing by IssuesController#create as XML Parameters: {"issue"=>`
{"project_id"=>"mt001", "subject"=>"TEST_AI", "tracker_id"=>"6",
"category_id"=>"136", "assigned_to_id"=>"4", "fixed_version_id"=>"93",
"priority_id"=>"2", "parent_issue_id"=>nil,
"start_date"=>"2016-05-30", "due_date"=>"2016-06-01",
"description"=>"Redmine TEST AI", "status_id"=>"1"},
"key"=>"XXXXXXX(hidden for security"}
Current user: user1 (id=65)
Completed 500 Internal Server Error in 367ms (ActiveRecord: 19.9ms)
NoMethodError (undefined method `shared_versions' for nil:NilClass):
app/models/issue.rb:823:in `assignable_versions'
app/models/issue.rb:643:in `validate_issue'
app/controllers/issues_controller.rb:141:in `create'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
So, I tried to create new issew using web browser (IE11).
The ticket was created normally. Here is production.log.
Started POST "/redmine/projects/mt001/issues" for XX.XX.XX.XXX at 2016-05-30 14:58:23 +0900
Processing by IssuesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"QF1BA5MgwysJsAiFfT/h95DeZ/VgzSGOnryR6xUn4mmWpf7EZ8XFJqpaye/ZLXrKR/wV00dKOz8KbhP94VcUyg==", "form_update_triggered_by"=>"", "issue"=>{"tracker_id"=>"6", "subject"=>"Test2", "description"=>"This is test", "status_id"=>"1", "priority_id"=>"2", "assigned_to_id"=>"4", "category_id"=>"132", "fixed_version_id"=>"127", "parent_issue_id"=>"", "start_date"=>"2016-05-30", "due_date"=>"2016-06-03", "custom_field_values"=>{"12"=>"", "41"=>""}}, "was_default_status"=>"1", "commit"=>"create", "project_id"=>"mt001"}
Current user: user1 (id=65)
Rendered mailer/_issue.text.erb (7.1ms)
Rendered mailer/issue_add.text.erb within layouts/mailer (9.8ms)
Rendered mailer/_issue.html.erb (3.0ms)
Rendered mailer/issue_add.html.erb within layouts/mailer (5.1ms)
Redirected to http://mydepartment.co.jp/redmine/issues/1717
Completed 302 Found in 3697ms (ActiveRecord: 130.3ms)
I already tried to migrate, clear cache.
What should I do next.
Here is my environment on RHEL7.2
Environment:
Redmine version 3.2.0.stable
Ruby version 2.2.4-p230 (2015-12-16) [x86_64-linux]
Rails version 4.2.5
Environment production
Database adapter Mysql2
SCM:
Subversion 1.7.14
Git 1.8.3.1
Filesystem
Redmine plugins:
redmine_export_with_journals 0.0.8
redmine_importer 1.2.2
redmine_local_avatars 1.0.0
redmine_xlsx_format_issue_exporter 0.1.2
sidebar_hide 0.0.7
Here is assinable_versions source-code
# Versions that the issue can be assigned to
def assignable_versions
return #assignable_versions if #assignable_versions
versions = project.shared_versions.open.to_a #Here is line823
if fixed_version
if fixed_version_id_changed?
# nothing to do
elsif project_id_changed?
if project.shared_versions.include?(fixed_version)
versions << fixed_version
end
else
versions << fixed_version
end
end
#assignable_versions = versions.uniq.sort
end
The error is occurring because project is nil and you are trying to call nil.shared_versions. So change the if condition:
if !project.shared_versions.nil?
versions = project.shared_versions.open.to_a
end
to as follows:
versions = project.shared_versions.open.to_a unless project.nil?
This will resolve the 'undefined method' error.
I've solved problem.
There is some difference of REST process.
At least redmine 2.4.4, I can use both project_id = identifier and project_id = project_id for issue create.
But, redmine 3.x, I can only use project_id = project_id for issue create.

Invalid connection string with jruby and oracle_enhaced adaptor

I've configured my rails app's database like the following.
test:
adapter: oracle_enhanced
host: localhost
database: localhost:1521/xe
username: test
password: test
pool: 50
wait_timeout: 10
tns: xe
It works using REE and oracled_enhanced adapter but doesn't work with jruby and instead gives the following error:
% rake spec
(in /home/xxxxxxxx)
rake aborted!
java.sql.SQLException: Io exception: Invalid connection string format, a valid format is: "host:port:sid"
I haven't yet been able to get it print the actual connection string that it tries to use. Running rake with --trace doesn't help either. Any ideas how I could get this to work?
Try this connection string:
test:
adapter: oracle_enhanced
driver: oracle.jdbc.pool.OracleDataSource
url: jdbc:oracle:thin:#localhost:1521:xe
...
That format works for me
/Mads
In my case this issue was resolved by making sure both ORACLE_HOME and TNS_ADMIN environment variables were set to the instant client installation directory:
$ echo $ORACLE_HOME
/Library/Oracle/instantclient/11.2.0.3.0
$ echo $TNS_ADMIN
/Library/Oracle/instantclient/11.2.0.3.0

Resources