view · edit · sidebar · attach · print · history

20160831-urgent-debug-sandoz-xmlconv-bbmb-ch

<< 20160901-urgent-debug-virbac-bbmb-ch-vetoquinol-bbmb-ch | Index | 20160830-migrate-and-prepare-release-davaz-com >>


Summary

  • Try to fix redirect issue on sandoz.xmlconv.bbmb.ch

Commits / Patches / Pull Requests, Scripts

  • Only urgent patches on production.

Index


Suddenly sandoz.xmlconv.bbmb.ch has turned to need flavored url (like /en/bbmb/transactions/xxx).
I'm not sure, but I think that specified load path by RubyAddPath does not work expectedly.
(We have upgraded davaz.com at yesterday).
Because at least application use 2 ruby and gems (one for mod_ruby, one for application process) for now. This situation and installation make this strange issue.

I've changed xmlconv-1.0.9 on production as emergency measure.

% git diff lib/
diff --git a/lib/xmlconv/custom/lookandfeel.rb b/lib/xmlconv/custom/lookandfeel.rb
index 986c42b..18046c8 100644
--- a/lib/xmlconv/custom/lookandfeel.rb
+++ b/lib/xmlconv/custom/lookandfeel.rb
@@ -49,13 +49,13 @@ module XmlConv
       alias :orig_base_url :base_url

       # Provides non flavored base url
-      def base_url
-        _flavor = @flavor
-        @flavor = nil
-        url = orig_base_url
-        @flavor = _flavor
-        url
-      end
+      #def base_url
+      #  _flavor = @flavor
+      #  @flavor = nil
+      #  url = orig_base_url
+      #  @flavor = _flavor
+      #  url
+      #end
                end
        end
 end

Remove RubyAddPath to gems for ruby 1.8.6

It must be use ydbi for executable.
currently sandoz.xmlconv.bbmb.ch use dbi, but installed ydbi for ruby 2.3.1 on production.
And for now I'm not able to use Bundler, untill fixing current messy installation.

I've updated gem env and apache config (mod_ruby) for sandoz.xmlconv.bbmb.ch to use gems installed for ruby 2.3.1.
Now, apache config file is like this:

RubyAddPath /var/www/sandoz.xmlconv.bbmb.ch/
# for API ({sunstore|propharma|pharmatic|pharmasoft|unilog|volksapotheke}.idx) [mod_ruby]
RubyAddPath /usr/local/lib/ruby/gems/2.3.0/gems/ydbi-0.5.3/lib
RubyAddPath /usr/local/lib/ruby/gems/2.3.0/gems/deprecated-2.0.1/lib
RubyAddPath /usr/local/lib/ruby/gems/2.3.0/gems/odba-1.1.2/lib
RubyAddPath /usr/local/lib/ruby/gems/2.3.0/gems/mail-2.6.4/lib
RubyAddPath /usr/local/lib/ruby/gems/2.3.0/gems/rclconf-1.0.0/lib
# sbsm
RubyAddPath /usr/local/lib/ruby/gems/2.3.0/gems/sbsm-1.3.0/lib
RubyRequire 'sbsm/trans_handler'
RubyTransHandler SBSM::TransHandler.instance
# xmlconv
RubyAddPath /usr/local/lib/ruby/gems/2.3.0/gems/xmlconv-1.0.9/lib
RubyRequire 'xmlconv/util/destination'
RubyRequire 'xmlconv/util/transaction'
  • update dbi-0.4.5 to ydbi-0.5.3
  • update odba-1.1.0 to odba-1.1.2
  • migrate tmail to mail-2.6.4
  • update sbsm-1.2.9 to sbsm-1.3.0
  • mod_ruby installed against ruby 1.8.6 (noch)
  • apache config has RubyAddPath for mod_ruby, but it uses gems installed ruby 2.3.1
  • application process (bbmbd, xmlconvd) runs on ruby 2.3.1

Fix corrupted data.

I was able to re-produte same error on production.
I have to debug update.

NoMethodError                                                                   
undefined method `add' for #<BBMB::Model::ProductInfo:0x005589ce48eba0>            
/path/to/bbmb/lib/bbmb/model/order.rb:34:in `method_missing'                       
/path/to/sandoz.bbmb.ch/.bundle/gems/ruby/2.3.0/gems/odba-1.1.2/lib/odba/stub.rb:112:in `method_missing'
/path/to/sandoz.bbmb.ch/lib/bbmb/util/csv_importer.rb:115:in `block (3 levels) in postprocess'
/path/to/sandoz.bbmb.ch/lib/bbmb/util/csv_importer.rb:114:in `each'                
/path/to/sandoz.bbmb.ch/lib/bbmb/util/csv_importer.rb:114:in `block (2 levels) in postprocess'
/path/to/sandoz.bbmb.ch/lib/bbmb/util/csv_importer.rb:113:in `each'                
/path/to/sandoz.bbmb.ch/lib/bbmb/util/csv_importer.rb:113:in `block in postprocess'
/path/to/sandoz.bbmb.ch/.bundle/gems/ruby/2.3.0/gems/odba-1.1.2/lib/odba/persistable.rb:150:in `block in odba_extent'
/path/to/sandoz.bbmb.ch/.bundle/gems/ruby/2.3.0/gems/odba-1.1.2/lib/odba/persistable.rb:150:in `each'
/path/to/sandoz.bbmb.ch/.bundle/gems/ruby/2.3.0/gems/odba-1.1.2/lib/odba/persistable.rb:150:in `odba_extent'
/path/to/bbmb/lib/bbmb/persistence/odba.rb:18:in `all'                             
/path/to/sandoz.bbmb.ch/lib/bbmb/util/csv_importer.rb:112:in `postprocess'         
/path/to/sandoz.bbmb.ch/lib/bbmb/util/csv_importer.rb:27:in `import'               
/path/to/bbmb/lib/bbmb/util/updater.rb:20:in `import'                              
/path/to/bbmb/lib/bbmb/util/updater.rb:14:in `block in run'                        
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:31:in `block in poll_path'          
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:30:in `open'                        
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:30:in `poll_path'                   
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:26:in `block in poll'               
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:25:in `each'                        
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:25:in `poll'                        
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:137:in `block in poll_sources'   
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:130:in `block in load_sources'   
/path/to/ruby/2.3.0/psych/deprecated.rb:32:in `each'                               
/path/to/ruby/2.3.0/psych/deprecated.rb:32:in `load_documents'                     
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:129:in `load_sources'               
/path/to/bbmb/lib/bbmb/util/polling_manager.rb:136:in `poll_sources'               
/path/to/bbmb/lib/bbmb/util/updater.rb:11:in `run'                                 
/path/to/bbmb/lib/bbmb/util/server.rb:161:in `update'                              
/path/to/bbmb/bin/update_articles_and_products:39:in `<module:BBMB>'               
/path/to/bbmb/bin/update_articles_and_products:10:in `<top (required)>'            
/path/to/sandoz.bbmb.ch/.bundle/gems/ruby/2.3.0/bin/update_articles_and_products:23:in `load'
/path/to/sandoz.bbmb.ch/.bundle/gems/ruby/2.3.0/bin/update_articles_and_products:23:in `<top (required)>'

It seems that ProductInfo object is saved as Order.

    persistence.all(BBMB::Model::Customer) { |customer|                         
      [customer.current_order, customer.favorites].each { |order|               
        deletables.each { |product|                                             
          order.add(0, product)            #=> here                                             
        }                                                                       
      }                                                                         
    }  

Debug via bin/admin

There is a strange object in Customer's current order.

ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').map {|c| \
c.class }.uniq
-> [BBMB::Model::Customer]
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').map {|c| \
 c.orders }.flatten.select {|o| o.class != BBMB::Model::Order }.length
-> 0
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').map {|c| \
c.current_order }.select {|o| o.class != BBMB::Model::Order }.length
-> 1
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').map {|c| \
c.favorites }.select {|o| o.class != BBMB::Model::Order }.length
-> 0

Customer ID 4100616254 has strange order as current order.

ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').map {|c| \
[c.customer_id, c.current_order] }.select {|id, o| [id, o] if o.class != BBMB::Model::Order }.first.first
-> 4100616254

This customer has not any order.

ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').find {|c|\
 c.customer_id == '4100616254' }.orders
-> []

Then we can remove this current_order.

How to remove it.

# fix
ch.bbmb.sandoz> c = ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').find {|c| \
c.customer_id == '4100616254' }; c.instance_variable_set(:@current_order, nil); c.odba_store
-> #<BBMB::Model::Customer:0x0055b5ed6b3f20>

# check
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_customer_customer_id', '').map {|c| \
[c.customer_id, c.current_order] }.select {|id, o| [id, o] if o.class != BBMB::Model::Order }.first.class
-> NilClass

Then updater works fine.

% bundle exec update_articles_and_products config=/var/www/sandoz.bbmb.ch/etc/config.yml
...
...
2016-08-31 19:53:30 +0200: Calling update
2016-08-31 19:53:30 +0200: Finished update
view · edit · sidebar · attach · print · history
Page last modified on September 02, 2016, at 09:12 AM