Description of problem: The initialize method for district is calling save! So if we query a list of 50 districts we do 50 saves. This is taking ~300ms in prod for every app create. Version-Release number of selected component (if applicable): How reproducible: 100% Steps to Reproduce: 1. Do anything that gets a district 2. 3. Actual results: It saves the district Expected results: It shouldn't save the district Additional info:
Correction: It looks like new isn't being called by mongoid on subsequent fetches. Looks like it might just be the amount of data being returned that's the issue.
The fix here is not to include available_uids when finding a node during app create.
https://github.com/openshift/origin-server/pull/3667
Verified on devenv_3810 1. Create 51 disctricst with oo-admin-ctl-district libra_rs:PRIMARY> db.districts.count() 51 2. Connect to datastore, verify the unique indexes have been enabled on the district collection libra_rs:PRIMARY> db.districts.getIndexes() [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "openshift_broker_dev.districts", "name" : "_id_" }, { "v" : 1, "key" : { "name" : 1 }, "unique" : true, "ns" : "openshift_broker_dev.districts", "name" : "name_1" }, { "v" : 1, "key" : { "uuid" : 1 }, "unique" : true, "ns" : "openshift_broker_dev.districts", "name" : "uuid_1" }, { "v" : 1, "key" : { "gear_size" : 1 }, "ns" : "openshift_broker_dev.districts", "name" : "gear_size_1" } ] 3. Query districts irb(main):007:0> require '/var/www/openshift/broker/config/environment' irb(main):007:0> require '/opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.15.0/app/models/district.rb' irb(main):052:0> a = Time.now;District.find_all();b = Time.now - a => 0.671984381 irb(main):053:0> a = Time.now;District.find_all(nil,false);b = Time.now - a => 0.005056106 Takes 5ms when uuids are not included in the query criterion。