Mysql2::Error: MySQL client is not connected: ROLLBACKの解決法
ruby on rails で課題ファイルをアップロードする機能を作っており、submits_controllerのcreateアクションを実行したところ、Mysql2::Error: MySQL client is not connected: ROLLBACKというエラー文が表示されました。
・時間内に実行が終わらなかったためにタイムアウトした。
・データの容量が大きいために実行できなかった。
と仮説を立て検証してみましたが解決には至りませんでした。
このような場合どのように対処すれば良いのでしょうか。また、MySQL clientがコネクトしていないという意味もいまいちわかりません。。
ご享受いただけると幸いです!
以下エラー文とソースコードと試したことです。
ソースコードは必要ならば追記します。
発生している問題・エラーメッセージ
![[(2a3586fb57ed78213627ae6805ad9d41.png)
### views/submits/new.html.erb <div class="contents row"> <%= form_for(@content, :url => {:controller => :submits, :action => :create}) do |f| %> <div class="field"> <%= f.file_field :upload_file %> </div> <div class="actions"> <%= f.submit "Upload" %> </div> <% end %> </div> new.html.erbからファイルを選択して、Uploadを押す controllers/submits_controller.rb class SubmitsController < ApplicationController def index end def new @content = Content.new end def create upload_file = content_params[:upload_file] content = {} if upload_file != nil content[:upload_file] = upload_file.read content[:upload_file_name] = upload_file.original_filename end @content = Content.new(content) respond_to do |format| if @content.save format.html { redirect_to ("/submits"), notice: 'Upload success' } format.json { render action: 'show', status: :created, location: @content } else @contents = Content.all format.html { render action: 'index' } format.json { render json: @content.errors, status: :unprocessable_entity } end end end private def content_params params.require(:content).permit(:upload_file) end end
試したこと
1、ターミナルでMySQLにログインする
2、以下のコマンドを実行
(タイムアウトする時間を長くする)
SET GLOBAL innodb_lock_wait_timeout = 28800;
(入れられるデータ容量の最大値を上げる)
SET GLOBAL max_allowed_packet = 4194304;
補足情報(FW/ツールのバージョンなど)
Rails 5.2.2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。