MongoId没有更新模型数据,也没有显示任何错误

问题描述

我有两个系统曾经使用mongo版本3.4.16在AWS平台上工作。目前,我将它们移至GCP,因此,我使用的是较新的mongo版本4.2.8。 您应该记住的第一件事是,在我更换服务器之前,这些系统已经工作了很多年。两者都使用相同的mongo服务器以及相同的集合和凭据。所以这是问题所在:

有问题的系统能够在MongoDB上查询和创建数据,但不能更新任何模型的任何属性。我试图使用也在Rails控制台上运行的Web界面来更新运行此应用程序的属性,它具有相同的问题。除了mongo版本,我没有做任何其他更改。

:023 > user = User.where({email: '[email protected]'}).first
:024 > user.name
 => "user name"
:025 > user.name = "new user name"
 => "new user name"
:026 > user.save!
 [paperclip] Saving attachments.
  => true
:027 > user = User.where({email: '[email protected]'}).first
:028 > user.name
 => "user name"

第二个系统具有相同的gem版本(当我谈论MongoDB gem时),并且即使将mongo版本从3.4.16更改为4.2.8,它仍在工作(更新模型属性)。 (正如我之前提到的)。您对可能发生的事情有任何想法吗?

有问题的系统宝石:

*** LOCAL GEMS ***

actionmailer (3.2.22.5)
actionpack (3.2.22.5)
activemodel (3.2.22.5)
activerecord (3.2.22.5)
activeresource (3.2.22.5)
activesupport (3.2.22.5)
addressable (2.5.0)
akami (1.3.1)
apipie-rails (0.3.7)
arel (3.0.3)
aws-sdk (1.66.0)
aws-sdk-v1 (1.66.0)
bcrypt (3.1.11)
better_errors (2.1.1)
bigdecimal (default: 1.2.8)
binding_of_caller (0.8.0)
bson (4.3.0,1.12.5)
bson_ext (1.12.5)
builder (3.0.4)
bundler (default: 1.17.3)
bundler-unload (1.0.2)
capybara (2.12.0)
client_side_validations (3.2.8)
cocaine (0.3.2)
coderay (1.1.1)
coffee-rails (3.2.2)
coffee-script (2.4.1)
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
connection_pool (2.2.1)
cpf_cnpj (0.3.0)
credit_card_validations (3.4.0)
cucumber (2.4.0)
cucumber-core (1.5.0)
cucumber-rails (1.4.5)
cucumber-wire (0.0.1)
daemons (1.2.6)
debug_inspector (0.0.3)
devise (3.5.10)
did_you_mean (1.0.0)
diff-lcs (1.3)
domain_name (0.5.20161129)
erubis (2.7.0)
eventmachine (1.2.2)
execjs (2.7.0)
executable-hooks (1.6.0)
faraday (0.11.0)
faraday_middleware (0.11.0.1)
faye-websocket (0.10.0)
figaro (1.1.1)
gem-wrappers (1.4.0)
geocoder (1.3.3)
gherkin (4.0.0)
google-geocode (1.2.1)
google_maps_service (0.4.2)
gyoku (1.3.1)
hike (1.2.3)
hiredis (0.6.1)
hoe (3.16.0)
http-cookie (1.0.3)
httparty (0.13.3)
httpi (2.4.2)
hurley (0.2)
i18n (0.9.5)
io-console (default: 0.4.5)
journey (1.0.4)
jquery-rails (3.1.4)
json (1.8.6,default: 1.8.3)
libv8 (3.16.14.19 x86_64-linux)
mail (2.5.5)
mime-types (1.25.1)
mini_portile (0.6.2)
minitest (5.11.3,5.8.3)
momentjs-rails (2.17.1)
mongo (2.6.2)
mongo_session_store-rails3 (6.0.0)
mongoid (3.1.7)
mongoid-geospatial (4.0.0)
mongoid-paperclip (0.0.11)
mongoid_userstamp (0.4.0)
moped (1.5.3)
multi_json (1.13.1)
multi_test (0.1.2)
multi_xml (0.6.0)
multipart-post (2.0.0)
net-http-persistent (1.9)
net-telnet (0.1.1)
netrc (0.11.0)
newrelic_mongodb (0.1.2)
newrelic_rpm (3.18.1.330)
nokogiri (1.6.6.4)
nori (2.6.0)
origin (1.1.0)
orm_adapter (0.5.0)
paperclip (3.1.1)
polyglot (0.3.5)
power_assert (1.0.1,0.2.6)
psych (default: 2.0.17)
public_suffix (2.0.5)
puma (3.12.0)
quiet_assets (1.1.0)
rack (1.4.7)
rack-cache (1.9.0)
rack-ssl (1.3.4)
rack-test (0.6.3)
rails (3.2.22.5)
railties (3.2.22.5)
rake (12.0.0,10.4.2)
rc-rest (4.0)
rdoc (default: 4.2.1,3.12.2)
redis (3.3.3)
redis-objects (1.2.1)
ref (2.0.0)
responders (1.1.2)
rest-client (2.0.0)
retriable (2.1.0)
rubygems-bundler (1.4.5)
rvm (1.11.3.9)
sass (3.4.23)
sass-rails (3.2.6)
savon (2.11.1)
socksify (1.7.1)
sprockets (2.2.3)
test-unit (3.2.3,3.1.5)
therubyracer (0.12.3)
thin (1.7.2)
thor (0.19.4)
thread_safe (0.3.5)
tilt (1.4.1)
treetop (1.4.15)
tzinfo (0.3.52)
uglifier (3.0.4)
unf (0.1.4)
unf_ext (0.0.7.2)
uuidtools (2.1.5)
warden (1.2.7)
wasabi (3.5.0)
websocket-driver (0.6.5)
websocket-extensions (0.1.2)
will_paginate (3.1.5)
will_paginate_mongoid (2.0.1)
xpath (2.0.0)

工作系统宝石:

*** LOCAL GEMS ***

actionmailer (3.2.22.5)
actionpack (3.2.22.5)
activemodel (3.2.22.5)
activerecord (3.2.22.5)
activeresource (3.2.22.5)
activesupport (3.2.22.5)
addressable (2.5.2,2.5.0)
adminlte2-rails (0.0.6)
akami (1.3.1)
apipie-rails (0.3.7)
arel (3.0.3)
autoprefixer-rails (8.2.0)
aws-sdk (1.67.0,1.66.0)
aws-sdk-v1 (1.67.0,1.66.0)
backports (3.11.1)
bcrypt (3.1.11)
better_errors (2.4.0,2.1.1)
bigdecimal (default: 1.2.8)
binding_of_caller (0.8.0)
bootstrap-sass (3.3.4.1)
bson (4.3.0,1.12.5)
bson_ext (1.12.5)
builder (3.0.4)
bundler (default: 1.17.3)
bundler-unload (1.0.2)
capybara (2.18.0,2.12.0)
chartkick (2.3.3)
client_side_validations (3.2.8)
climate_control (0.2.0)
cocaine (0.6.0,0.3.2)
coderay (1.1.2,1.1.1)
coffee-rails (3.2.2)
coffee-script (2.4.1)
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5,1.0.5)
connection_pool (2.2.2,2.2.1)
cpf_cnpj (0.4.1,0.3.0)
credit_card_validations (3.5.0,3.4.0)
cucumber (3.1.0,2.4.0)
cucumber-core (3.1.0,1.5.0)
cucumber-expressions (5.0.14)
cucumber-rails (1.4.5)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
daemons (1.2.6)
debug_inspector (0.0.3)
declarative (0.0.10)
declarative-option (0.1.0)
devise (3.5.10)
did_you_mean (1.0.0)
diff-lcs (1.3)
domain_name (0.5.20170404,0.5.20161129)
dropzonejs-rails (0.8.2)
erubi (1.7.1)
erubis (2.7.0)
eventmachine (1.2.7,1.2.2)
execjs (2.7.0)
executable-hooks (1.6.0)
faraday (0.12.2,0.11.0)
faraday_middleware (0.12.2,0.11.0.1)
faye-websocket (0.10.0)
fcm (0.0.2)
ffi (1.9.23)
figaro (1.1.1)
gem-wrappers (1.4.0)
geocoder (1.3.3)
gherkin (5.0.0,4.0.0)
google-api-client (0.10.3)
google-geocode (1.2.1)
google_maps_service (0.4.2)
googleauth (0.6.2)
gyoku (1.3.1)
hike (1.2.3)
hiredis (0.6.1)
hoe (3.16.0)
http-cookie (1.0.3)
httparty (0.13.3)
httpclient (2.8.3)
httpi (2.4.3,2.4.2)
hurley (0.2)
i18n (0.9.5)
io-console (default: 0.4.5)
journey (1.0.4)
jquery-rails (3.1.4)
jquery_mask_rails (0.1.0)
json (1.8.6,default: 1.8.3)
jwt (1.5.6)
libv8 (3.16.14.19 x86_64-linux)
little-plugger (1.1.4)
logging (2.2.2)
mail (2.5.5)
memoist (0.16.0)
mime-types (1.25.1)
mini_mime (1.0.0)
mini_portile (0.6.2)
mini_portile2 (2.3.0)
minitest (5.11.3,5.8.3)
momentjs-rails (2.20.1,2.17.1)
mongo (2.6.2)
mongo_session_store-rails3 (6.0.0)
mongoid (3.1.7)
mongoid-geospatial (4.0.0)
mongoid-paperclip (0.0.11)
mongoid_userstamp (0.4.0)
moped (1.5.3)
multi_json (1.13.1)
multi_test (0.1.2)
multi_xml (0.6.0)
multipart-post (2.0.0)
net-http-persistent (1.9)
net-telnet (0.1.1)
netrc (0.11.0)
newrelic_mongodb (0.1.2)
newrelic_rpm (5.3.0.346,3.18.1.330)
nokogiri (1.8.2,1.6.6.4)
nori (2.6.0)
origin (1.1.0)
orm_adapter (0.5.0)
os (0.9.6)
pagarme (2.2.2)
pagy (3.4.1)
paperclip (3.1.1)
polyglot (0.3.5)
power_assert (1.1.1,1.0.1,0.2.6)
psych (default: 2.0.17)
public_suffix (3.0.2,2.0.5)
puma (3.12.0,3.11.3)
quiet_assets (1.1.0)
rack (1.4.7)
rack-cache (1.9.0,1.8.0)
rack-ssl (1.3.4)
rack-test (0.6.3)
rails (3.2.22.5)
railties (3.2.22.5)
rake (12.3.1,12.0.0,10.4.2)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
rc-rest (4.0)
rdoc (default: 4.2.1,3.12.2)
redis (4.0.1,3.3.3)
redis-objects (1.4.0,1.2.1)
ref (2.0.0)
representable (3.0.4)
responders (1.1.2)
rest-client (2.0.2,2.0.0)
retriable (2.1.0)
rubygems-bundler (1.4.5)
rvm (1.11.3.9)
sass (3.5.6,3.4.23)
sass-listen (4.0.0)
sass-rails (3.2.6)
savon (2.12.0,2.11.1)
signet (0.8.1)
socksify (1.7.1)
sprockets (2.2.3)
terrapin (0.6.0)
test-unit (3.2.7,3.2.3,3.1.5)
therubyracer (0.12.3)
thin (1.7.2)
thor (0.20.0,0.19.4)
thread_safe (0.3.6,0.3.5)
tilt (1.4.1)
time_difference (0.5.0)
treetop (1.4.15)
tzinfo (0.3.54,0.3.52)
uber (0.1.0)
uglifier (3.2.0,3.0.4)
unf (0.1.4)
unf_ext (0.0.7.5,0.0.7.2)
uuidtools (2.1.5)
warden (1.2.7)
wasabi (3.5.0)
websocket-driver (0.7.0,0.6.5)
websocket-extensions (0.1.3,0.1.2)
will_paginate (3.1.6,3.1.5)
will_paginate_mongoid (2.0.1)
xpath (3.0.0,2.0.0)

我以前从未见过这样的东西。

解决方法

使用command monitoring来确定/验证正在发送什么命令以及将什么命令发送到哪个数据库。

通过mongo shell检查集合,以在更新前后验证其内容。