title: Unexplained massive number of shopping Carts in Rails database in Production
body: <p>I built an e-commerce app using Rails 5, postgres and heroku,  with a classic shopping Cart using the session object to store the cart_id. Thanks to a warning from heroku, I discovered that the numbers of Carts in my database was increasing in a very weird way. It can be more than 50 per minute; and it's not due to many customers visiting the site, which is quite small for the moment. At other moments, the numbers of rows of the Carts table is stable.</p>
  <p>Here is my application controller:</p>
  <pre><code>class ApplicationController &lt; ActionController::Base
  
    protect_from_forgery with: :exception
    around_action :switch_locale
  
    before_action :configure_permitted_parameters, if: :devise_controller?
    before_action  :current_cart
    after_action :store_action
  
  
    def switch_locale(&amp;action)
    locale = params[:locale] || I18n.default_locale
    I18n.with_locale(locale, &amp;action)
    end
  
    def default_url_options
      { locale: I18n.locale == I18n.default_locale ? nil : I18n.locale }
    end
  
  
    def current_cart
  
          if session[:cart_id]
            cart = Cart.find_by_id(session[:cart_id])
            if cart == nil
              session[:cart_id] = nil
            end
  
            if cart.present?
              @current_cart = cart
            else
              session[:cart_id] = nil
            end
          end
  
  
          if session[:cart_id] == nil
            @current_cart = Cart.create
            session[:cart_id] = @current_cart.id
          end
    end
  
  
    def store_action
        return unless request.get?
        if (request.path != &quot;/users/sign_in&quot; &amp;&amp;
            request.path != &quot;/users/sign_up&quot; &amp;&amp;
            request.path != &quot;/users/password/new&quot; &amp;&amp;
            request.path != &quot;/users/password/edit&quot; &amp;&amp;
            request.path != &quot;/users/confirmation&quot; &amp;&amp;
            request.path != &quot;/users/sign_out&quot; &amp;&amp;
            !request.xhr?) # don't store ajax calls
          store_location_for(:user, request.fullpath)
        end
      end
  
    protected
  
    def configure_permitted_parameters
      devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
    end
  </code></pre>
  <p>end</p>
  <p>cart.rb</p>
  <pre><code>class Cart &lt; ApplicationRecord
    has_many :order_items, dependent: :destroy
    has_many :products, through: :order_items
    monetize :amount_cents_cents
  end
  </code></pre>
  <p>and the Orders controller:</p>
  <pre><code>class OrdersController &lt; ApplicationController
  
    before_action :authenticate_user!
  
    def create
      @order = Order.new
  
      total = []
      @current_cart.order_items.each do |item|
  
        total &lt;&lt; item.product.price_cents * item.quantity.to_i
      end
  
      @order.amount_cents_cents = total.sum
  
      if @order.amount_cents_cents == 0
         Cart.destroy(session[:cart_id])
         session[:cart_id] = nil
         redirect_to root_path
      else
        @current_cart.order_items.each do |item|
          @order.order_items &lt;&lt; item
          item.cart_id = nil
        end
  
        @user = current_user
        @order.user_id = @user.id
        @order.save
  
  
        Cart.destroy(session[:cart_id])
        session[:cart_id] = nil
  
        redirect_to order_path(@order)
      end
  </code></pre>
  <p>Here are Heroku logs from yesterday :</p>
  <pre><code>2021-03-09T16:25:31.994631+00:00 app[web.1]: D, [2021-03-09T16:25:31.994568 #4] DEBUG -- : [bc4f12a5-b503-435a-bd45-eac3c3adc006]   Cart Create (1.1ms)  INSERT INTO &quot;carts&quot; (&quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2) RETURNING &quot;id&quot;  [[&quot;created_at&quot;, &quot;2021-03-09 16:25:31.993019&quot;], [&quot;updated_at&quot;, &quot;2021-03-09 16:25:31.993019&quot;]]
  2021-03-09T16:25:31.996727+00:00 app[web.1]: D, [2021-03-09T16:25:31.996649 #4] DEBUG -- : [bc4f12a5-b503-435a-bd45-eac3c3adc006]    (1.8ms)  COMMIT
  2021-03-09T16:25:31.998717+00:00 app[web.1]: D, [2021-03-09T16:25:31.998636 #4] DEBUG -- : [bc4f12a5-b503-435a-bd45-eac3c3adc006]   OrderItem Load (1.1ms)  SELECT &quot;order_items&quot;.* FROM &quot;order_items&quot; WHERE &quot;order_items&quot;.&quot;cart_id&quot; = $1  [[&quot;cart_id&quot;, 102580]]
  2021-03-09T16:25:31.999401+00:00 app[web.1]: I, [2021-03-09T16:25:31.999343 #4]  INFO -- : [bc4f12a5-b503-435a-bd45-eac3c3adc006]   Rendering carts/show.html.erb within layouts/application
  2021-03-09T16:25:32.000698+00:00 app[web.1]: I, [2021-03-09T16:25:32.000634 #4]  INFO -- : [bc4f12a5-b503-435a-bd45-eac3c3adc006]   Rendered carts/show.html.erb within layouts/application (1.2ms)
  2021-03-09T16:25:32.003572+00:00 app[web.1]: I, [2021-03-09T16:25:32.003492 #4]  INFO -- : [bc4f12a5-b503-435a-bd45-eac3c3adc006]   Rendered shared/_navbar.html.erb (2.0ms)
  2021-03-09T16:25:32.003861+00:00 app[web.1]: I, [2021-03-09T16:25:32.003787 #4]  INFO -- : [bc4f12a5-b503-435a-bd45-eac3c3adc006]   Rendered shared/_flashes.html.erb (0.1ms)
  2021-03-09T16:25:32.004305+00:00 app[web.1]: I, [2021-03-09T16:25:32.004209 #4]  INFO -- : [bc4f12a5-b503-435a-bd45-eac3c3adc006] Completed 200 OK in 14ms (Views: 5.0ms | ActiveRecord: 5.0ms)
  2021-03-09T16:25:32.006089+00:00 heroku[router]: at=info method=GET path=&quot;/en/carts/100155&quot; host=www.bravacoffeeroasters.com request_id=bc4f12a5-b503-435a-bd45-eac3c3adc006 fwd=&quot;5.9.108.254&quot; dyno=web.1 connect=0ms service=20ms status=200 bytes=8003 protocol=https
  2021-03-09T16:25:39.827045+00:00 app[web.1]: I, [2021-03-09T16:25:39.826944 #4]  INFO -- : [794133c6-3a8d-4952-b38b-148dd1c78941] Started GET &quot;/en/carts/100158&quot; for 5.9.108.254 at 2021-03-09 16:25:39 +0000
  2021-03-09T16:25:39.828020+00:00 app[web.1]: I, [2021-03-09T16:25:39.827942 #4]  INFO -- : [794133c6-3a8d-4952-b38b-148dd1c78941] Processing by CartsController#show as HTML
  2021-03-09T16:25:39.828070+00:00 app[web.1]: I, [2021-03-09T16:25:39.828014 #4]  INFO -- : [794133c6-3a8d-4952-b38b-148dd1c78941]   Parameters: {&quot;locale&quot;=&gt;&quot;en&quot;, &quot;id&quot;=&gt;&quot;100158&quot;}
  2021-03-09T16:25:39.831671+00:00 app[web.1]: D, [2021-03-09T16:25:39.831585 #4] DEBUG -- : [794133c6-3a8d-4952-b38b-148dd1c78941]    (1.2ms)  BEGIN
  2021-03-09T16:25:39.834022+00:00 app[web.1]: D, [2021-03-09T16:25:39.833931 #4] DEBUG -- : [794133c6-3a8d-4952-b38b-148dd1c78941]   Cart Create (1.3ms)  INSERT INTO &quot;carts&quot; (&quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2) RETURNING &quot;id&quot;  [[&quot;created_at&quot;, &quot;2021-03-09 16:25:39.832057&quot;], [&quot;updated_at&quot;, &quot;2021-03-09 16:25:39.832057&quot;]]
  2021-03-09T16:25:39.836952+00:00 app[web.1]: D, [2021-03-09T16:25:39.836843 #4] DEBUG -- : [794133c6-3a8d-4952-b38b-148dd1c78941]    (2.6ms)  COMMIT
  2021-03-09T16:25:39.838769+00:00 app[web.1]: D, [2021-03-09T16:25:39.838664 #4] DEBUG -- : [794133c6-3a8d-4952-b38b-148dd1c78941]   OrderItem Load (1.1ms)  SELECT &quot;order_items&quot;.* FROM &quot;order_items&quot; WHERE &quot;order_items&quot;.&quot;cart_id&quot; = $1  [[&quot;cart_id&quot;, 102581]]
  2021-03-09T16:25:39.839411+00:00 app[web.1]: I, [2021-03-09T16:25:39.839342 #4]  INFO -- : [794133c6-3a8d-4952-b38b-148dd1c78941]   Rendering carts/show.html.erb within layouts/application
  2021-03-09T16:25:39.840887+00:00 app[web.1]: I, [2021-03-09T16:25:39.840812 #4]  INFO -- : [794133c6-3a8d-4952-b38b-148dd1c78941]   Rendered carts/show.html.erb within layouts/application (1.4ms)
  2021-03-09T16:25:39.843830+00:00 app[web.1]: I, [2021-03-09T16:25:39.843767 #4]  INFO -- : [794133c6-3a8d-4952-b38b-148dd1c78941]   Rendered shared/_navbar.html.erb (2.0ms)
  2021-03-09T16:25:39.844041+00:00 app[web.1]: I, [2021-03-09T16:25:39.843979 #4]  INFO -- : [794133c6-3a8d-4952-b38b-148dd1c78941]   Rendered shared/_flashes.html.erb (0.1ms)
  2021-03-09T16:25:39.844419+00:00 app[web.1]: I, [2021-03-09T16:25:39.844315 #4]  INFO -- : [794133c6-3a8d-4952-b38b-148dd1c78941] Completed 200 OK in 16ms (Views: 5.1ms | ActiveRecord: 6.2ms)
  2021-03-09T16:25:39.846119+00:00 heroku[router]: at=info method=GET path=&quot;/en/carts/100158&quot; host=www.bravacoffeeroasters.com request_id=794133c6-3a8d-4952-b38b-148dd1c78941 fwd=&quot;5.9.108.254&quot; dyno=web.1 connect=0ms service=21ms status=200 bytes=8007 protocol=https
  2021-03-09T16:25:44.393247+00:00 app[web.1]: I, [2021-03-09T16:25:44.393143 #4]  INFO -- : [55da48a9-0088-4a3d-984a-f58f8a81245a] Started GET &quot;/en/carts/100162&quot; for 5.9.108.254 at 2021-03-09 16:25:44 +0000
  2021-03-09T16:25:44.394349+00:00 app[web.1]: I, [2021-03-09T16:25:44.394257 #4]  INFO -- : [55da48a9-0088-4a3d-984a-f58f8a81245a] Processing by CartsController#show as HTML
  2021-03-09T16:25:44.394397+00:00 app[web.1]: I, [2021-03-09T16:25:44.394331 #4]  INFO -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]   Parameters: {&quot;locale&quot;=&gt;&quot;en&quot;, &quot;id&quot;=&gt;&quot;100162&quot;}
  2021-03-09T16:25:44.402068+00:00 app[web.1]: D, [2021-03-09T16:25:44.401988 #4] DEBUG -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]    (1.0ms)  BEGIN
  2021-03-09T16:25:44.404434+00:00 app[web.1]: D, [2021-03-09T16:25:44.404308 #4] DEBUG -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]   Cart Create (1.2ms)  INSERT INTO &quot;carts&quot; (&quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2) RETURNING &quot;id&quot;  [[&quot;created_at&quot;, &quot;2021-03-09 16:25:44.402575&quot;], [&quot;updated_at&quot;, &quot;2021-03-09 16:25:44.402575&quot;]]
  2021-03-09T16:25:44.406742+00:00 app[web.1]: D, [2021-03-09T16:25:44.406662 #4] DEBUG -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]    (1.9ms)  COMMIT
  2021-03-09T16:25:44.408565+00:00 app[web.1]: D, [2021-03-09T16:25:44.408479 #4] DEBUG -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]   OrderItem Load (1.0ms)  SELECT &quot;order_items&quot;.* FROM &quot;order_items&quot; WHERE &quot;order_items&quot;.&quot;cart_id&quot; = $1  [[&quot;cart_id&quot;, 102582]]
  2021-03-09T16:25:44.409183+00:00 app[web.1]: I, [2021-03-09T16:25:44.409106 #4]  INFO -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]   Rendering carts/show.html.erb within layouts/application
  2021-03-09T16:25:44.410524+00:00 app[web.1]: I, [2021-03-09T16:25:44.410452 #4]  INFO -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]   Rendered carts/show.html.erb within layouts/application (1.2ms)
  2021-03-09T16:25:44.413558+00:00 app[web.1]: I, [2021-03-09T16:25:44.413470 #4]  INFO -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]   Rendered shared/_navbar.html.erb (2.0ms)
  2021-03-09T16:25:44.413840+00:00 app[web.1]: I, [2021-03-09T16:25:44.413772 #4]  INFO -- : [55da48a9-0088-4a3d-984a-f58f8a81245a]   Rendered shared/_flashes.html.erb (0.1ms)
  2021-03-09T16:25:44.414160+00:00 app[web.1]: I, [2021-03-09T16:25:44.414098 #4]  INFO -- : [55da48a9-0088-4a3d-984a-f58f8a81245a] Completed 200 OK in 20ms (Views: 5.1ms | ActiveRecord: 5.2ms)
  2021-03-09T16:25:44.416182+00:00 heroku[router]: at=info method=GET path=&quot;/en/carts/100162&quot; host=www.bravacoffeeroasters.com request_id=55da48a9-0088-4a3d-984a-f58f8a81245a fwd=&quot;5.9.108.254&quot; dyno=web.1 connect=0ms service=25ms status=200 bytes=8001 protocol=https
  2021-03-09T16:25:49.749861+00:00 app[web.1]: I, [2021-03-09T16:25:49.749718 #4]  INFO -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5] Started GET &quot;/en/carts/100167&quot; for 5.9.108.254 at 2021-03-09 16:25:49 +0000
  2021-03-09T16:25:49.751269+00:00 app[web.1]: I, [2021-03-09T16:25:49.751173 #4]  INFO -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5] Processing by CartsController#show as HTML
  2021-03-09T16:25:49.751359+00:00 app[web.1]: I, [2021-03-09T16:25:49.751277 #4]  INFO -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]   Parameters: {&quot;locale&quot;=&gt;&quot;en&quot;, &quot;id&quot;=&gt;&quot;100167&quot;}
  2021-03-09T16:25:49.754570+00:00 app[web.1]: D, [2021-03-09T16:25:49.754464 #4] DEBUG -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]    (1.1ms)  BEGIN
  2021-03-09T16:25:49.757801+00:00 app[web.1]: D, [2021-03-09T16:25:49.757693 #4] DEBUG -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]   Cart Create (1.2ms)  INSERT INTO &quot;carts&quot; (&quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2) RETURNING &quot;id&quot;  [[&quot;created_at&quot;, &quot;2021-03-09 16:25:49.755581&quot;], [&quot;updated_at&quot;, &quot;2021-03-09 16:25:49.755581&quot;]]
  2021-03-09T16:25:49.760623+00:00 app[web.1]: D, [2021-03-09T16:25:49.760418 #4] DEBUG -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]    (2.2ms)  COMMIT
  2021-03-09T16:25:49.762818+00:00 app[web.1]: D, [2021-03-09T16:25:49.762617 #4] DEBUG -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]   OrderItem Load (1.1ms)  SELECT &quot;order_items&quot;.* FROM &quot;order_items&quot; WHERE &quot;order_items&quot;.&quot;cart_id&quot; = $1  [[&quot;cart_id&quot;, 102583]]
  2021-03-09T16:25:49.764416+00:00 app[web.1]: I, [2021-03-09T16:25:49.764303 #4]  INFO -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]   Rendering carts/show.html.erb within layouts/application
  2021-03-09T16:25:49.766505+00:00 app[web.1]: I, [2021-03-09T16:25:49.766423 #4]  INFO -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]   Rendered carts/show.html.erb within layouts/application (1.9ms)
  2021-03-09T16:25:49.771851+00:00 app[web.1]: I, [2021-03-09T16:25:49.771765 #4]  INFO -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]   Rendered shared/_navbar.html.erb (3.8ms)
  2021-03-09T16:25:49.772151+00:00 app[web.1]: I, [2021-03-09T16:25:49.772072 #4]  INFO -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5]   Rendered shared/_flashes.html.erb (0.1ms)
  2021-03-09T16:25:49.772669+00:00 app[web.1]: I, [2021-03-09T16:25:49.772589 #4]  INFO -- : [c9f138de-a820-4b0b-b87e-ad2f99f6c9f5] Completed 200 OK in 21ms (Views: 8.7ms | ActiveRecord: 5.7ms)
  2021-03-09T16:25:49.775098+00:00 heroku[router]: at=info method=GET path=&quot;/en/carts/100167&quot; host=www.bravacoffeeroasters.com request_id=c9f138de-a820-4b0b-b87e-ad2f99f6c9f5 fwd=&quot;5.9.108.254&quot; dyno=web.1 connect=0ms service=28ms status=200 bytes=8005 protocol=https
  2021-03-09T16:25:55.885797+00:00 app[web.1]: I, [2021-03-09T16:25:55.885705 #4]  INFO -- : [e2305a65-52be-432a-867f-ac1c0f459e1b] Started GET &quot;/en/carts/100171&quot; for 5.9.108.254 at 2021-03-09 16:25:55 +0000
  2021-03-09T16:25:55.886791+00:00 app[web.1]: I, [2021-03-09T16:25:55.886726 #4]  INFO -- : [e2305a65-52be-432a-867f-ac1c0f459e1b] Processing by CartsController#show as HTML
  2021-03-09T16:25:55.886851+00:00 app[web.1]: I, [2021-03-09T16:25:55.886800 #4]  INFO -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]   Parameters: {&quot;locale&quot;=&gt;&quot;en&quot;, &quot;id&quot;=&gt;&quot;100171&quot;}
  2021-03-09T16:25:55.889588+00:00 app[web.1]: D, [2021-03-09T16:25:55.889521 #4] DEBUG -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]    (1.0ms)  BEGIN
  2021-03-09T16:25:55.891685+00:00 app[web.1]: D, [2021-03-09T16:25:55.891611 #4] DEBUG -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]   Cart Create (1.2ms)  INSERT INTO &quot;carts&quot; (&quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2) RETURNING &quot;id&quot;  [[&quot;created_at&quot;, &quot;2021-03-09 16:25:55.889991&quot;], [&quot;updated_at&quot;, &quot;2021-03-09 16:25:55.889991&quot;]]
  2021-03-09T16:25:55.894147+00:00 app[web.1]: D, [2021-03-09T16:25:55.894080 #4] DEBUG -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]    (2.1ms)  COMMIT
  2021-03-09T16:25:55.895883+00:00 app[web.1]: D, [2021-03-09T16:25:55.895820 #4] DEBUG -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]   OrderItem Load (1.1ms)  SELECT &quot;order_items&quot;.* FROM &quot;order_items&quot; WHERE &quot;order_items&quot;.&quot;cart_id&quot; = $1  [[&quot;cart_id&quot;, 102584]]
  2021-03-09T16:25:55.896595+00:00 app[web.1]: I, [2021-03-09T16:25:55.896512 #4]  INFO -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]   Rendering carts/show.html.erb within layouts/application
  2021-03-09T16:25:55.898042+00:00 app[web.1]: I, [2021-03-09T16:25:55.897982 #4]  INFO -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]   Rendered carts/show.html.erb within layouts/application (1.4ms)
  2021-03-09T16:25:55.900969+00:00 app[web.1]: I, [2021-03-09T16:25:55.900906 #4]  INFO -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]   Rendered shared/_navbar.html.erb (2.0ms)
  2021-03-09T16:25:55.901154+00:00 app[web.1]: I, [2021-03-09T16:25:55.901098 #4]  INFO -- : [e2305a65-52be-432a-867f-ac1c0f459e1b]   Rendered shared/_flashes.html.erb (0.0ms)
  2021-03-09T16:25:55.901439+00:00 app[web.1]: I, [2021-03-09T16:25:55.901385 #4]  INFO -- : [e2305a65-52be-432a-867f-ac1c0f459e1b] Completed 200 OK in 14ms (Views: 5.1ms | ActiveRecord: 5.3ms)
  2021-03-09T16:25:55.903393+00:00 heroku[router]: at=info method=GET path=&quot;/en/carts/100171&quot; host=www.bravacoffeeroasters.com request_id=e2305a65-52be-432a-867f-ac1c0f459e1b fwd=&quot;5.9.108.254&quot; dyno=web.1 connect=0ms service=20ms status=200 bytes=8005 protocol=https
  2021-03-09T16:26:02.095206+00:00 app[web.1]: I, [2021-03-09T16:26:02.095107 #4]  INFO -- : [59ebb736-4614-4052-97dd-9517cfd2af70] Started GET &quot;/en/carts/100176&quot; for 5.9.108.254 at 2021-03-09 16:26:02 +0000
  2021-03-09T16:26:02.096223+00:00 app[web.1]: I, [2021-03-09T16:26:02.096121 #4]  INFO -- : [59ebb736-4614-4052-97dd-9517cfd2af70] Processing by CartsController#show as HTML
  2021-03-09T16:26:02.096287+00:00 app[web.1]: I, [2021-03-09T16:26:02.096209 #4]  INFO -- : [59ebb736-4614-4052-97dd-9517cfd2af70]   Parameters: {&quot;locale&quot;=&gt;&quot;en&quot;, &quot;id&quot;=&gt;&quot;100176&quot;}
  2021-03-09T16:26:02.099292+00:00 app[web.1]: D, [2021-03-09T16:26:02.099195 #4] DEBUG -- : [59ebb736-4614-4052-97dd-9517cfd2af70]    (1.0ms)  BEGIN
  2021-03-09T16:26:02.101864+00:00 app[web.1]: D, [2021-03-09T16:26:02.101787 #4] DEBUG -- : [59ebb736-4614-4052-97dd-9517cfd2af70]   Cart Create (1.3ms)  INSERT INTO &quot;carts&quot; (&quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2) RETURNING &quot;id&quot;  [[&quot;created_at&quot;, &quot;2021-03-09 16:26:02.099815&quot;], [&quot;updated_at&quot;, &quot;2021-03-09 16:26:02.099815&quot;]]
  2021-03-09T16:26:02.104590+00:00 app[web.1]: D, [2021-03-09T16:26:02.104462 #4] DEBUG -- : [59ebb736-4614-4052-97dd-9517cfd2af70]    (2.3ms)  COMMIT
  2021-03-09T16:26:02.106692+00:00 app[web.1]: D, [2021-03-09T16:26:02.106619 #4] DEBUG -- : [59ebb736-4614-4052-97dd-9517cfd2af70]   OrderItem Load (1.3ms)  SELECT &quot;order_items&quot;.* FROM &quot;order_items&quot; WHERE &quot;order_items&quot;.&quot;cart_id&quot; = $1  [[&quot;cart_id&quot;, 102585]]
  2021-03-09T16:26:02.107212+00:00 app[web.1]: I, [2021-03-09T16:26:02.107150 #4]  INFO -- : [59ebb736-4614-4052-97dd-9517cfd2af70]   Rendering carts/show.html.erb within layouts/application
  2021-03-09T16:26:02.108495+00:00 app[web.1]: I, [2021-03-09T16:26:02.108422 #4]  INFO -- : [59ebb736-4614-4052-97dd-9517cfd2af70]   Rendered carts/show.html.erb within layouts/application (1.2ms)
  2021-03-09T16:26:02.111100+00:00 app[web.1]: I, [2021-03-09T16:26:02.111034 #4]  INFO -- : [59ebb736-4614-4052-97dd-9517cfd2af70]   Rendered shared/_navbar.html.erb (1.7ms)
  2021-03-09T16:26:02.111294+00:00 app[web.1]: I, [2021-03-09T16:26:02.111230 #4]  INFO -- : [59ebb736-4614-4052-97dd-9517cfd2af70]   Rendered shared/_flashes.html.erb (0.1ms)
  2021-03-09T16:26:02.111695+00:00 app[web.1]: I, [2021-03-09T16:26:02.111563 #4]  INFO -- : [59ebb736-4614-4052-97dd-9517cfd2af70] Completed 200 OK in 15ms (Views: 4.5ms | ActiveRecord: 5.9ms)
  2021-03-09T16:26:02.114053+00:00 heroku[router]: at=info method=GET path=&quot;/en/carts/100176&quot; host=www.bravacoffeeroasters.com request_id=59ebb736-4614-4052-97dd-9517cfd2af70 fwd=&quot;5.9.108.254&quot; dyno=web.1 connect=0ms service=21ms status=200 bytes=8011 protocol=https
  2021-03-09T16:26:07.168587+00:00 app[web.1]: I, [2021-03-09T16:26:07.168395 #4]  INFO -- : [512ac9cd-da40-435d-a7b8-986ad4209a31] Started GET &quot;/en/carts/100181&quot; for 5.9.108.254 at 2021-03-09 16:26:07 +0000
  2021-03-09T16:26:07.169524+00:00 app[web.1]: I, [2021-03-09T16:26:07.169461 #4]  INFO -- : [512ac9cd-da40-435d-a7b8-986ad4209a31] Processing by CartsController#show as HTML
  2021-03-09T16:26:07.169585+00:00 app[web.1]: I, [2021-03-09T16:26:07.169533 #4]  INFO -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]   Parameters: {&quot;locale&quot;=&gt;&quot;en&quot;, &quot;id&quot;=&gt;&quot;100181&quot;}
  2021-03-09T16:26:07.172559+00:00 app[web.1]: D, [2021-03-09T16:26:07.172490 #4] DEBUG -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]    (1.0ms)  BEGIN
  2021-03-09T16:26:07.174639+00:00 app[web.1]: D, [2021-03-09T16:26:07.174577 #4] DEBUG -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]   Cart Create (1.2ms)  INSERT INTO &quot;carts&quot; (&quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2) RETURNING &quot;id&quot;  [[&quot;created_at&quot;, &quot;2021-03-09 16:26:07.172954&quot;], [&quot;updated_at&quot;, &quot;2021-03-09 16:26:07.172954&quot;]]
  2021-03-09T16:26:07.176801+00:00 app[web.1]: D, [2021-03-09T16:26:07.176731 #4] DEBUG -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]    (1.9ms)  COMMIT
  2021-03-09T16:26:07.178631+00:00 app[web.1]: D, [2021-03-09T16:26:07.178567 #4] DEBUG -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]   OrderItem Load (1.1ms)  SELECT &quot;order_items&quot;.* FROM &quot;order_items&quot; WHERE &quot;order_items&quot;.&quot;cart_id&quot; = $1  [[&quot;cart_id&quot;, 102586]]
  2021-03-09T16:26:07.179179+00:00 app[web.1]: I, [2021-03-09T16:26:07.179119 #4]  INFO -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]   Rendering carts/show.html.erb within layouts/application
  2021-03-09T16:26:07.180626+00:00 app[web.1]: I, [2021-03-09T16:26:07.180554 #4]  INFO -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]   Rendered carts/show.html.erb within layouts/application (1.3ms)
  2021-03-09T16:26:07.183396+00:00 app[web.1]: I, [2021-03-09T16:26:07.183332 #4]  INFO -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]   Rendered shared/_navbar.html.erb (1.9ms)
  2021-03-09T16:26:07.183592+00:00 app[web.1]: I, [2021-03-09T16:26:07.183524 #4]  INFO -- : [512ac9cd-da40-435d-a7b8-986ad4209a31]   Rendered shared/_flashes.html.erb (0.0ms)
  2021-03-09T16:26:07.183924+00:00 app[web.1]: I, [2021-03-09T16:26:07.183852 #4]  INFO -- : [512ac9cd-da40-435d-a7b8-986ad4209a31] Completed 200 OK in 14ms (Views: 4.8ms | ActiveRecord: 5.1ms)
  2021-03-09T16:26:07.186556+00:00 heroku[router]: at=info method=GET path=&quot;/en/carts/100181&quot; host=www.bravacoffeeroasters.com request_id=512ac9cd-da40-435d-a7b8-986ad4209a31 fwd=&quot;5.9.108.254&quot; dyno=web.1 connect=0ms service=20ms status=200 bytes=8009 protocol=https
  2021-03-09T16:26:12.791059+00:00 app[web.1]: I, [2021-03-09T16:26:12.790956 #4]  INFO -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9] Started GET &quot;/en/carts/100185&quot; for 5.9.108.254 at 2021-03-09 16:26:12 +0000
  2021-03-09T16:26:12.792005+00:00 app[web.1]: I, [2021-03-09T16:26:12.791938 #4]  INFO -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9] Processing by CartsController#show as HTML
  2021-03-09T16:26:12.792075+00:00 app[web.1]: I, [2021-03-09T16:26:12.792011 #4]  INFO -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]   Parameters: {&quot;locale&quot;=&gt;&quot;en&quot;, &quot;id&quot;=&gt;&quot;100185&quot;}
  2021-03-09T16:26:12.794860+00:00 app[web.1]: D, [2021-03-09T16:26:12.794781 #4] DEBUG -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]    (1.0ms)  BEGIN
  2021-03-09T16:26:12.797433+00:00 app[web.1]: D, [2021-03-09T16:26:12.797358 #4] DEBUG -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]   Cart Create (1.2ms)  INSERT INTO &quot;carts&quot; (&quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2) RETURNING &quot;id&quot;  [[&quot;created_at&quot;, &quot;2021-03-09 16:26:12.795289&quot;], [&quot;updated_at&quot;, &quot;2021-03-09 16:26:12.795289&quot;]]
  2021-03-09T16:26:12.799742+00:00 app[web.1]: D, [2021-03-09T16:26:12.799657 #4] DEBUG -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]    (1.8ms)  COMMIT
  2021-03-09T16:26:12.801691+00:00 app[web.1]: D, [2021-03-09T16:26:12.801618 #4] DEBUG -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]   OrderItem Load (1.2ms)  SELECT &quot;order_items&quot;.* FROM &quot;order_items&quot; WHERE &quot;order_items&quot;.&quot;cart_id&quot; = $1  [[&quot;cart_id&quot;, 102587]]
  2021-03-09T16:26:12.802222+00:00 app[web.1]: I, [2021-03-09T16:26:12.802153 #4]  INFO -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]   Rendering carts/show.html.erb within layouts/application
  2021-03-09T16:26:12.803798+00:00 app[web.1]: I, [2021-03-09T16:26:12.803727 #4]  INFO -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]   Rendered carts/show.html.erb within layouts/application (1.5ms)
  2021-03-09T16:26:12.807236+00:00 app[web.1]: I, [2021-03-09T16:26:12.807070 #4]  INFO -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]   Rendered shared/_navbar.html.erb (2.3ms)
  2021-03-09T16:26:12.807516+00:00 app[web.1]: I, [2021-03-09T16:26:12.807446 #4]  INFO -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9]   Rendered shared/_flashes.html.erb (0.1ms)
  2021-03-09T16:26:12.807908+00:00 app[web.1]: I, [2021-03-09T16:26:12.807840 #4]  INFO -- : [ee78de9f-ffb9-4c3b-a484-8438903fd9c9] Completed 200 OK in 16ms (Views: 5.8ms | ActiveRecord: 5.2ms)
  2021-03-09T16:26:12.809202+00:00 heroku[router]: at=info method=GET path=&quot;/en/carts/100185&quot; host=www.bravacoffeeroasters.com request_id=ee78de9f-ffb9-4c3b-a484-8438903fd9c9 fwd=&quot;5.9.108.254&quot; dyno=web.1 connect=0ms service=20ms status=200 bytes=8013 protocol=https
  </code></pre>
  <p>I deleted all the Carts of the production database yesterday and today I have already more than 3000 rows. This sounds bad to me. Is anyone could help fixing the problem?</p>