You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
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:
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!
The text was updated successfully, but these errors were encountered: