Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem with Parallel Gem and The MySQL server is running with the --read-only #324

Closed
leesanghun6310 opened this issue Jun 27, 2022 · 2 comments

Comments

@leesanghun6310
Copy link

leesanghun6310 commented Jun 27, 2022

How to resolve this problem..

Summary:I try to improvement one slowing api of my service via Parallel Gem

Problem:the error is occured in other part of the codes that I didn't added parallel gem's logic. occured code is include Create・Update・delete process

error message:

Mysql2::Error: The MySQL server is running with the --read-only option so it cannot execute this statement: "UPDATE ~~~"
def hogehoge(data)
  hogehoge = Parallel.map(data) do |data|
    ActiveRecord::Base.using(:slave1).connection.reconnect!
    ActiveRecord::Base.using(:master).connection.reconnect!

    adjust_fields() → contain business logic
  end
  ActiveRecord::Base.using(:slave1).connection.reconnect!
  ActiveRecord::Base.using(:master).connection.reconnect!

  return hogehoge
end

Info

1.DB's composition of My service is master and some slave (read only)

2.function which want to improvemnt is not include Create・Update・delete process

I also post Stack Overflow also
link:https://stackoverflow.com/posts/72766225

Thank you!

@grosser
Copy link
Owner

grosser commented Jun 27, 2022

did not see something like that before, very strange ... I'm mostly expecting this to be either logic bug in adjust_fields or somehow queries being buffered in the connection

  • use Parallel.map(data, in_processes: 0) do to see if it's caused by fork
  • remove adjust_fields and see if it also happens
  • simplify adjust_fields by removing more and more code until it stops happening

@grosser
Copy link
Owner

grosser commented Jun 27, 2022

stackoverflow is gone, so I assume this was solved ...

@grosser grosser closed this as completed Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants