5

I have recently migrated from 4 to latest 5.1 rails (and from thin to puma server). I have a non-repeatable error and I am not able to trace it's source. Below is a an example application backtrace:

  app/views/reports/_transaction_dialog.html.erb:88:in `_app_views_report=
s__transaction_dialog_html_erb___259516699_72100400'
  app/views/reports/show.html.erb:40:in `block in _app_views_reports_show=
_html_erb___439575899_73388840'
  app/views/reports/show.html.erb:38:in `_app_views_reports_show_html_erb=
___439575899_73388840'
  app/controllers/application_controller.rb:52:in `block in select_shard'=

  app/controllers/application_controller.rb:48:in `select_shard'

I know it does not say much... it is just a partial rendering. It happens in various places of the code but usually in a place where app uses flipper to check for feature availability. Here _transaction_dialog.html.erb:88 has:

      <% if $flipper[:schooling].enabled? current_user %>

I will try to report it to flipper but maybe someone has other idea? I use octopus for database sharding. Gemfile.lock below:

GIT
  remote: https://github.com/zquestz/omniauth-google-oauth2
  revision: 605f483311a1885d87fa636791faba109ff37221
  branch: master
  specs:
    omniauth-google-oauth2 (0.5.2)
      jwt (~> 1.5)
      omniauth (>= 1.1.1)
      omniauth-oauth2 (>= 1.3.1)

GEM
  remote: https://rubygems.org/
  remote: https://rails-assets.org/
  specs:
    actioncable (5.1.4)
      actionpack (= 5.1.4)
      nio4r (~> 2.0)
      websocket-driver (~> 0.6.1)
    actionmailer (5.1.4)
      actionpack (= 5.1.4)
      actionview (= 5.1.4)
      activejob (= 5.1.4)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.1.4)
      actionview (= 5.1.4)
      activesupport (= 5.1.4)
      rack (~> 2.0)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.1.4)
      activesupport (= 5.1.4)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activejob (5.1.4)
      activesupport (= 5.1.4)
      globalid (>= 0.3.6)
    activemodel (5.1.4)
      activesupport (= 5.1.4)
    activerecord (5.1.4)
      activemodel (= 5.1.4)
      activesupport (= 5.1.4)
      arel (~> 8.0)
    activerecord-sqlserver-adapter (5.1.2)
      activerecord (~> 5.1.0)
      tiny_tds
    activesupport (5.1.4)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (~> 0.7)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    addressable (2.5.2)
      public_suffix (>= 2.0.2, < 4.0)
    ar-octopus (0.9.1)
      activerecord (>= 4.0.0)
      activesupport (>= 4.0.0)
    arel (8.0.0)
    autoprefixer-rails (7.1.6)
      execjs
    axlsx (1.3.6)
      htmlentities (~> 4.3.1)
      nokogiri (>= 1.4.1)
      rubyzip (>= 0.9.5)
    bcrypt (3.1.11-x64-mingw32)
    bcrypt (3.1.11-x86-mingw32)
    bootstrap-sass (3.3.7)
      autoprefixer-rails (>= 5.2.1)
      sass (>= 3.3.4)
    bootstrap_form (2.7.0)
    builder (3.2.3)
    byebug (9.1.0)
    cmxl (0.2.0)
      rchardet19
    cocoon (1.2.11)
    coffee-rails (4.2.2)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.12.2)
    concurrent-ruby (1.0.5)
    crass (1.0.3)
    declarative (0.0.10)
    declarative-option (0.1.0)
    devise (4.3.0)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0, < 5.2)
      responders
      warden (~> 1.2.3)
    devise_ldap_authenticatable (0.8.5)
      devise (>= 3.4.1)
      net-ldap (>= 0.6.0, <= 0.11)
    docx (0.2.07)
      nokogiri (~> 1.5)
      rubyzip (~> 1.1.6)
    erubi (1.7.0)
    erubis (2.7.0)
    exception_notification (4.2.2)
      actionmailer (>= 4.0, < 6)
      activesupport (>= 4.0, < 6)
    execjs (2.7.0)
    faraday (0.12.2)
      multipart-post (>= 1.2, < 3)
    ffi (1.9.18-x64-mingw32)
    ffi (1.9.18-x86-mingw32)
    flipper (0.11.0)
    flipper-ui (0.11.0)
      erubis (~> 2.7.0)
      flipper (~> 0.11.0)
      rack (>= 1.4, < 3)
      rack-protection (>= 1.5.3, < 2.1.0)
    globalid (0.4.1)
      activesupport (>= 4.2.0)
    gmail (0.6.0)
      gmail_xoauth (>= 0.3.0)
      mail (>= 2.2.1)
    gmail_xoauth (0.4.2)
      oauth (>= 0.3.6)
    google-api-client (0.17.3)
      addressable (~> 2.5, >= 2.5.1)
      googleauth (>= 0.5, < 0.7.0)
      httpclient (>= 2.8.1, < 3.0)
      mime-types (~> 3.0)
      representable (~> 3.0)
      retriable (>= 2.0, < 4.0)
    googleauth (0.6.2)
      faraday (~> 0.12)
      jwt (>= 1.4, < 3.0)
      logging (~> 2.0)
      memoist (~> 0.12)
      multi_json (~> 1.11)
      os (~> 0.9)
      signet (~> 0.7)
    googlecharts (1.6.12)
    hashie (3.5.6)
    htmlentities (4.3.4)
    httpclient (2.8.3)
    i18n (0.9.1)
      concurrent-ruby (~> 1.0)
    jwt (1.5.6)
    little-plugger (1.1.4)
    logging (2.2.2)
      little-plugger (~> 1.1)
      multi_json (~> 1.10)
    loofah (2.1.1)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.0)
      mini_mime (>= 0.1.1)
    memoist (0.16.0)
    method_source (0.9.0)
    mime-types (3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0521)
    mini_mime (1.0.0)
    mini_portile2 (2.3.0)
    minitest (5.10.3)
    money (6.10.0)
      i18n (>= 0.6.4, < 1.0)
    multi_json (1.12.2)
    multi_logger (0.1.0)
      railties
    multi_xml (0.6.0)
    multipart-post (2.0.0)
    net-ldap (0.11)
    nio4r (2.1.0)
    nokogiri (1.8.1-x64-mingw32)
      mini_portile2 (~> 2.3.0)
    nokogiri (1.8.1-x86-mingw32)
      mini_portile2 (~> 2.3.0)
    oauth (0.5.3)
    oauth2 (1.4.0)
      faraday (>= 0.8, < 0.13)
      jwt (~> 1.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (>= 1.2, < 3)
    omniauth (1.7.1)
      hashie (>= 3.4.6, < 3.6.0)
      rack (>= 1.6.2, < 3)
    omniauth-oauth2 (1.4.0)
      oauth2 (~> 1.0)
      omniauth (~> 1.2)
    orm_adapter (0.5.0)
    os (0.9.6)
    public_suffix (3.0.1)
    puma (3.11.0)
    rack (2.0.3)
    rack-protection (2.0.0)
      rack
    rack-test (0.8.2)
      rack (>= 1.0, < 3)
    rails (5.1.4)
      actioncable (= 5.1.4)
      actionmailer (= 5.1.4)
      actionpack (= 5.1.4)
      actionview (= 5.1.4)
      activejob (= 5.1.4)
      activemodel (= 5.1.4)
      activerecord (= 5.1.4)
      activesupport (= 5.1.4)
      bundler (>= 1.3.0)
      railties (= 5.1.4)
      sprockets-rails (>= 2.0.0)
    rails-assets-fullcalendar (3.7.0)
      rails-assets-jquery (>= 2, < 4)
      rails-assets-moment (>= 2.9.0, < 3)
    rails-assets-fullcalendar-scheduler (1.9.0)
      rails-assets-fullcalendar (~> 3.7.0)
      rails-assets-jquery (>= 2, < 4)
      rails-assets-moment (>= 2.9.0, < 3)
    rails-assets-jquery (3.2.1)
    rails-assets-jquery-ui (1.12.1)
      rails-assets-jquery (>= 1.6)
    rails-assets-jquery-ujs (1.2.2)
      rails-assets-jquery (> 1.8)
    rails-assets-jqueryui-timepicker-addon (1.6.3)
    rails-assets-js-cookie (2.2.0)
    rails-assets-lightbox (2.10.0)
      rails-assets-jquery (> 2)
    rails-assets-moment (2.19.3)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    railties (5.1.4)
      actionpack (= 5.1.4)
      activesupport (= 5.1.4)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (12.3.0)
    rb-fsevent (0.10.2)
    rb-inotify (0.9.10)
      ffi (>= 0.5.0, < 2)
    rchardet19 (1.3.7)
    representable (3.0.4)
      declarative (< 0.1.0)
      declarative-option (< 0.2.0)
      uber (< 0.2.0)
    responders (2.4.0)
      actionpack (>= 4.2.0, < 5.3)
      railties (>= 4.2.0, < 5.3)
    retriable (3.1.1)
    ruby-oci8 (2.2.5-x64-mingw32)
    ruby-oci8 (2.2.5-x86-mingw32)
    rubyzip (1.1.7)
    sass (3.5.3)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sass-rails (5.0.7)
      railties (>= 4.0.0, < 6)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    signet (0.8.1)
      addressable (~> 2.3)
      faraday (~> 0.9)
      jwt (>= 1.5, < 3.0)
      multi_json (~> 1.10)
    sprockets (3.7.1)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sqlite3 (1.3.13-x64-mingw32)
    sqlite3 (1.3.13-x86-mingw32)
    thor (0.20.0)
    thread_safe (0.3.6)
    tilt (2.0.8)
    tiny_tds (2.1.0-x64-mingw32)
    tiny_tds (2.1.0-x86-mingw32)
    tzinfo (1.2.4)
      thread_safe (~> 0.1)
    tzinfo-data (1.2017.3)
      tzinfo (>= 1.0.0)
    uber (0.1.0)
    uglifier (3.2.0)
      execjs (>= 0.3.0, < 3)
    warden (1.2.7)
      rack (>= 1.0)
    websocket-driver (0.6.5)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)
    zip (2.0.2)

PLATFORMS
  x64-mingw32
  x86-mingw32

DEPENDENCIES
  activerecord-sqlserver-adapter
  ar-octopus
  axlsx
  bootstrap-sass
  bootstrap_form
  byebug
  cmxl
  cocoon
  coffee-rails
  devise
  devise_ldap_authenticatable
  docx
  exception_notification
  flipper
  flipper-ui
  gmail
  google-api-client
  googleauth
  googlecharts
  money
  multi_logger
  omniauth-google-oauth2!
  puma
  rails
  rails-assets-fullcalendar!
  rails-assets-fullcalendar-scheduler!
  rails-assets-jquery!
  rails-assets-jquery-ui!
  rails-assets-jquery-ujs!
  rails-assets-jqueryui-timepicker-addon!
  rails-assets-js-cookie!
  rails-assets-lightbox!
  ruby-oci8
  sass-rails
  sqlite3
  tiny_tds
  tzinfo-data
  uglifier
  zip

BUNDLED WITH
   1.16.0

This is what I see in nginx log:

10.86.12.240 - - [27/Dec/2017:13:44:12 +0000] "GET / HTTP/2.0" 200 5589 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"
10.86.12.240 - - [27/Dec/2017:13:44:18 +0000] "GET /reports/3576 HTTP/2.0" 499 0 "https://quick.roche.com/" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"
10.86.12.240 - - [27/Dec/2017:13:44:19 +0000] "GET /reports/3576 HTTP/2.0" 200 7802 "https://quick.roche.com/" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"

successful (http status=200) request for initial page, then 499 and 200 afterwards

499 is what gives me error in rails stack

this is what I have in rails logs for those last two requests:

I, [2017-12-27T13:44:18.744420 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d] Started GET "/reports/3576" for 127.0.0.1 at 2017-12-27 13:44:18 +0000
I, [2017-12-27T13:44:18.744420 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d] Processing by ReportsController#show as HTML
I, [2017-12-27T13:44:18.744420 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Parameters: {"id"=>"3576"}
D, [2017-12-27T13:44:18.744420 #1760] DEBUG -- : [1226f679-086e-4699-a6de-cab43006d58d] [1m[32m[Shard: ir][0m  [1m[36mUser Load (0.0ms)[0m  [1m[35mEXEC sp_executesql N'SELECT  [users].* FROM [users] WHERE [users].[login] = @0  ORDER BY name ASC OFFSET 0 ROWS FETCH NEXT @1 ROWS ONLY', N'@0 varchar(8), @1 int', @0 = 'sh', @1 = 1[0m  [["login", nil], ["LIMIT", nil]]
D, [2017-12-27T13:44:18.744420 #1760] DEBUG -- : [1226f679-086e-4699-a6de-cab43006d58d] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (0.0ms)[0m  [1m[35mEXEC Delegators @ToolName = N'WebT&E', @user = N'sh', @permission = N'% REPORT'[0m
I, [2017-12-27T13:44:18.869223 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502] Started GET "/reports/3576" for 127.0.0.1 at 2017-12-27 13:44:18 +0000
I, [2017-12-27T13:44:18.869223 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502] Processing by ReportsController#show as HTML
I, [2017-12-27T13:44:18.869223 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Parameters: {"id"=>"3576"}
D, [2017-12-27T13:44:18.869223 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mUser Load (0.0ms)[0m  [1m[35mEXEC sp_executesql N'SELECT  [users].* FROM [users] WHERE [users].[login] = @0  ORDER BY name ASC OFFSET 0 ROWS FETCH NEXT @1 ROWS ONLY', N'@0 varchar(8), @1 int', @0 = 'sh', @1 = 1[0m  [["login", nil], ["LIMIT", nil]]
D, [2017-12-27T13:44:18.869223 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (0.0ms)[0m  [1m[35mEXEC Delegators @ToolName = N'WebT&E', @user = N'sh', @permission = N'% REPORT'[0m
D, [2017-12-27T13:44:19.212432 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (343.2ms)[0m  [1m[35mEXEC GetParameters @ToolName = N'WebT&E', @user = N'sh', @user_direct = N'sh', @report_id = N'3576'[0m
D, [2017-12-27T13:44:19.212432 #1760] DEBUG -- : [1226f679-086e-4699-a6de-cab43006d58d] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (468.0ms)[0m  [1m[35mEXEC GetParameters @ToolName = N'WebT&E', @user = N'sh', @user_direct = N'sh', @report_id = N'3576'[0m
D, [2017-12-27T13:44:19.212432 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mUser Load (0.0ms)[0m  [1m[35mEXEC sp_executesql N'SELECT  [users].* FROM [users] WHERE [users].[login] = @0  ORDER BY name ASC OFFSET 0 ROWS FETCH NEXT @1 ROWS ONLY', N'@0 varchar(8), @1 int', @0 = 'mp', @1 = 1[0m  [["login", nil], ["LIMIT", nil]]
I, [2017-12-27T13:44:19.212432 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Rendering reports/show.html.erb within layouts/application
D, [2017-12-27T13:44:19.212432 #1760] DEBUG -- : [1226f679-086e-4699-a6de-cab43006d58d] [1m[32m[Shard: ir][0m  [1m[36mUser Load (0.0ms)[0m  [1m[35mEXEC sp_executesql N'SELECT  [users].* FROM [users] WHERE [users].[login] = @0  ORDER BY name ASC OFFSET 0 ROWS FETCH NEXT @1 ROWS ONLY', N'@0 varchar(8), @1 int', @0 = 'mp', @1 = 1[0m  [["login", nil], ["LIMIT", nil]]
I, [2017-12-27T13:44:19.212432 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendering reports/show.html.erb within layouts/application
D, [2017-12-27T13:44:19.228033 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mComment Load (15.6ms)[0m  [1m[34mSELECT [comments].* FROM [comments] WHERE (entity='Report' AND entity_id=N'3576')[0m
D, [2017-12-27T13:44:19.228033 #1760] DEBUG -- : [1226f679-086e-4699-a6de-cab43006d58d] [1m[32m[Shard: ir][0m  [1m[36mComment Load (15.6ms)[0m  [1m[34mSELECT [comments].* FROM [comments] WHERE (entity='Report' AND entity_id=N'3576')[0m
I, [2017-12-27T13:44:19.243633 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered reports/_transactions.html.erb (15.6ms)
I, [2017-12-27T13:44:19.243633 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Rendered reports/_transactions.html.erb (15.6ms)
I, [2017-12-27T13:44:19.243633 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered reports/_summary.html.erb (31.2ms)
I, [2017-12-27T13:44:19.243633 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Rendered reports/_summary.html.erb (31.2ms)
I, [2017-12-27T13:44:19.243633 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered reports/show.html.erb within layouts/application (31.2ms)
I, [2017-12-27T13:44:19.243633 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d] Completed 500 Internal Server Error in 499ms (ActiveRecord: 483.6ms)
I, [2017-12-27T13:44:19.259233 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendering F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb
I, [2017-12-27T13:44:19.274834 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/_request.text.erb (0.0ms)
D, [2017-12-27T13:44:19.274834 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (31.2ms)[0m  [1m[35mEXEC account_groups @user = N'mp'[0m
I, [2017-12-27T13:44:19.290434 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
I, [2017-12-27T13:44:19.290434 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/_session.text.erb (0.0ms)
I, [2017-12-27T13:44:19.290434 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
I, [2017-12-27T13:44:19.306035 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/_environment.text.erb (0.0ms)
D, [2017-12-27T13:44:19.306035 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (15.6ms)[0m  [1m[35mEXEC accounts_for @user = N'mp', @group = N'Travel'[0m
I, [2017-12-27T13:44:19.306035 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
I, [2017-12-27T13:44:19.306035 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/_backtrace.text.erb (0.0ms)
I, [2017-12-27T13:44:19.306035 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
I, [2017-12-27T13:44:19.306035 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d]   Rendered F:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/exception_notification-4.2.2/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb (46.8ms)
D, [2017-12-27T13:44:19.306035 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (0.0ms)[0m  [1m[35mEXEC accounts_for @user = N'mp', @group = N'Congress'[0m
D, [2017-12-27T13:44:19.306035 #1760] DEBUG -- : [1226f679-086e-4699-a6de-cab43006d58d] #exception_notification: processed outbound mail in 62.4ms
D, [2017-12-27T13:44:19.321635 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (15.6ms)[0m  [1m[35mEXEC accounts_for @user = N'mp', @group = N'Other'[0m
D, [2017-12-27T13:44:19.399637 #1760] DEBUG -- : [9817073b-8d80-4516-ba8d-040e223d1502] [1m[32m[Shard: ir][0m  [1m[36mExecute Procedure (78.0ms)[0m  [1m[35mEXEC UnreportedRequests @ToolName = N'WebT&E', @user = N'mp', @ReportId = 3576[0m
I, [2017-12-27T13:44:19.399637 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Rendered reports/_transaction_dialog.html.erb (156.0ms)
I, [2017-12-27T13:44:19.399637 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Rendered reports/_split_dialog.html.erb (0.0ms)
I, [2017-12-27T13:44:19.399637 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Rendered reports/_travel_dialog.html.erb (0.0ms)
I, [2017-12-27T13:44:19.399637 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Rendered reports/_additionals_dialog.html.erb (0.0ms)
I, [2017-12-27T13:44:19.399637 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502]   Rendered reports/show.html.erb within layouts/application (187.2ms)
I, [2017-12-27T13:44:19.399637 #1760]  INFO -- : [9817073b-8d80-4516-ba8d-040e223d1502] Completed 200 OK in 530ms (Views: 36.4ms | ActiveRecord: 499.2ms)
I, [2017-12-27T13:44:19.477639 #1760]  INFO -- : [1226f679-086e-4699-a6de-cab43006d58d] Sent mail to krzysztof.chodak@... (171.6ms)

It looks to me like there were two the same requests and one of them has failed with 'nested transaction' error from ActiveRecord (is it AR? class of the error actually is ActionView::Template::Error)...

I do not see any "nested transaction" in rails source...

First question is why there are two requests in rails from the same client and almost the same second?

Second question is why such parallel requests do fail?

I have searched all my gem sources for "nested transaction" and I do not see it - I am not able to locate the code raising this error :(

Kodak
  • 1,779
  • 2
  • 18
  • 29
  • is it solved? Can you check on devtools if there are actually two requests made by the client and what triggers those requests? – Alexandre Wiechers Vaz Jan 09 '18 at 13:35
  • it is too early to say: I have removed all db transaction from rails and also from stored procedures used by rails and I do not have this error for 5 days now but it may be the fact that there are less users now; it might be some non-committed transaction causing this error on next db connection usage – Kodak Jan 09 '18 at 16:13
  • funny thing is that after I rebooted the application (after adding some functionalities) I have plenty of those again :( – Kodak Jan 20 '18 at 17:45

1 Answers1

0

I was finally able to reproduce this error on development: I was doubleclicking a link causing two nearly simultaneous requests. The actual "nested transaction" error came from the flipper's PStore.

Solution:

  • reduce number of Flipper's feature calls by using $flipper.preload([]) with an array of features' names and adding 5 minutes ActiveSupportCacheStore cache over PStore

  • disable consecutive link's usage

To be checked whether it is effective on production but development tests look promising.

update1: it just reduces the number off errors - thread safety option on PStore needs to be enabled by patching the flipper

update2: https://github.com/jnunemaker/flipper/pull/334

Kodak
  • 1,779
  • 2
  • 18
  • 29