view · edit · sidebar · attach · print · history


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


  • Try to fix redirect issue on

Commits / Patches / Pull Requests, Scripts

  • Only urgent patches on production.


Suddenly 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 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

Remove RubyAddPath to gems for ruby 1.8.6

It must be use ydbi for executable.
currently 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 to use gems installed for ruby 2.3.1.
Now, apache config file is like this:

RubyAddPath /var/www/
# 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.

undefined method `add' for #<BBMB::Model::ProductInfo:0x005589ce48eba0>            
/path/to/bbmb/lib/bbmb/model/order.rb:34:in `method_missing'                       
/path/to/ `method_missing'
/path/to/ `block (3 levels) in postprocess'
/path/to/ `each'                
/path/to/ `block (2 levels) in postprocess'
/path/to/ `each'                
/path/to/ `block in postprocess'
/path/to/ `block in odba_extent'
/path/to/ `each'
/path/to/ `odba_extent'
/path/to/bbmb/lib/bbmb/persistence/odba.rb:18:in `all'                             
/path/to/ `postprocess'         
/path/to/ `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/ `load'
/path/to/ `<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 } {|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/
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