{"id":390484,"date":"2024-06-29T09:16:18","date_gmt":"2024-06-29T09:16:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=390484"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=390484","title":{"rendered":"<span>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437 \u0432 1000 \u043b\u0435\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u0430\u043a \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u043c\u043d\u044e, \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a 25\u0435 \u043e\u043a\u0442\u044f\u0431\u0440\u044f, \u044f \u0437\u0430\u0441\u0442\u0443\u043f\u0430\u044e \u043d\u0430 \u0434\u0435\u0436\u0443\u0440\u0441\u0442\u0432\u043e \u043f\u043e \u043f\u0440\u043e\u0434\u0443 \u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0443\u0442\u0440\u0430 \u043c\u043d\u0435 \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430: \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432 \u043d\u043e\u0447\u044c \u0441 24 \u043d\u0430 25 \u043e\u043a\u0442\u044f\u0431\u0440\u044f, \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0413\u043b\u044f\u043d\u0443\u0432 \u0441\u0435\u043d\u0442\u0440\u0438 \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u043a\u0443\u0447\u0443 \u043e\u0448\u0438\u0431\u043e\u043a \u043e\u0442 \u0431\u0430\u0437\u044b \u0441\u043e statement timeout, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 <code>ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.<\/code> \u0421 \u043c\u044b\u0441\u043b\u044c\u044e &#171;\u0431\u0430\u0437\u0430 \u043d\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u043b\u0430, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u043d\u0430 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435&#187; \u044f \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043e\u0442\u0434\u0430\u043b \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0430\u0434\u043c\u0438\u043d\u0430\u043c, \u0430 \u0441\u0430\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0433\u043b\u044f\u043d\u0443\u043b \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043c \u0431\u044b\u043b \u0432\u0441\u043f\u043b\u0435\u0441\u043a \u043a\u0430\u043a\u0438\u0445-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0436\u043e\u0431\u043e\u043a \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043a\u0440\u0438\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u0433\u0440\u0430\u0444\u0430\u043d\u0435 \u043d\u0435\u0431\u044b\u043b\u043e: \u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u044b\u0445 \u0434\u0436\u043e\u0431\u043e\u043a \u0432 12 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u0430 \u0442\u0435, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e. <\/p>\n<p>\u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0432\u043e\u043d\u043e\u0447\u0435\u043a. \u0414\u043b\u044f \u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0432\u043e\u0434\u043d\u0443\u044e: \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0440\u0435\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414: \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u0441\u0430\u0439\u0434\u043a\u0438\u043a\u0430, \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u043b\u044f \u0430\u043f\u043f \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0442\u0440\u0435\u0442\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0443 \u043d\u0438\u0445 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f statement timeout&#8217;\u043e\u043c: \u0434\u043b\u044f \u0430\u043f\u043f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043e\u043d \u0441\u043e\u0432\u0441\u0435\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439, \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u043e\u0432 \u0447\u0443\u0442\u044c \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u0443 \u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043e\u043d \u0432\u043e\u0432\u0441\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u0422\u0430\u043a \u0432\u043e\u0442, \u0432 12 \u0447\u0430\u0441\u043e\u0432 \u043d\u043e\u0447\u0438 \u0440\u0435\u0437\u043a\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 \u044e\u0437\u0435\u0440\u043e\u043c migrations. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c51\/694\/518\/c51694518c6239306e1910f53157166a.jpg\" width=\"1204\" height=\"297\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c51\/694\/518\/c51694518c6239306e1910f53157166a.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u042f \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b, \u0447\u0442\u043e \u0432 12 \u0447\u0430\u0441\u043e\u0432 \u0443 \u043d\u0430\u0441 \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u0434\u0436\u043e\u0431\u044b \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<pre><code class=\"yaml\">round_partitions_job:   cron: '0 0 25 * *'  # At 00:00 on day-of-month 25   class: RoundPartitionsJob processed_events_partitions_job:   cron: '0 0 25 * *'  # At 00:00 on day-of-month 25   class: ProcessedEventsPartitionsJob user_balance_changes_partition_job:   cron: '0 0 25 * *'  # At 00:00 on day-of-month 25   class: UserBalanceChangesPartitionJob <\/code><\/pre>\n<p>\u0425\u043c\u043c, \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u044d\u0442\u0438 \u0434\u0436\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u043f\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c migrations \u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438. \u041d\u043e \u044d\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0438\u043a\u0430\u043a \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b, \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432 \u0431\u044b\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u043e, \u043a\u0430\u043a \u043e\u043d\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<pre><code class=\"ruby\">Rails.root.join(\"config\", \"database.migrations.yml\")       .yield_self(&amp;File.method(:read))       .yield_self { |f| ERB.new(f).result }       .yield_self(&amp;YAML.method(:load))       .dig(Rails.env)       .yield_self(&amp;ActiveRecord::Base.method(:establish_connection))<\/code><\/pre>\n<p>\u0421\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0443 \u043d\u0430\u0441 \u0440\u0435\u0437\u043a\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u043a\u043e\u043b-\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 migrations \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u043b\u0438 ActiveRecord::Base.connection. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b \u0434\u0436\u043e\u0431\u043a\u0443 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434 \u0441\u0432\u043e\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434 migrations \u044e\u0437\u0435\u0440\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0437\u0430\u0442\u0443\u043f\u044b \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0439 \u043a\u043e\u0441\u044f\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u041d\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0441\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c: \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0438\u043b\u043e \u0442\u043e\u043b\u044c\u043a\u043e 15 \u043c\u0438\u043d\u0443\u0442, \u0430 \u043f\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0443 migrations \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u043f\u043e\u043b\u0443\u043d\u043e\u0447\u0438 \u0434\u043e 12 \u0434\u043d\u044f. \u0417\u043d\u0430\u0447\u0438\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432 \u044d\u0442\u043e\u043c. \u0418\u043b\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u043c, \u0434\u0443\u043c\u0430\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0432 \u043b\u043e\u0433\u0438 \u0431\u0430\u0437\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 rounds:<\/p>\n<pre><code class=\"sql\">[vxid:80\/29134748 txid:0] [idle in transaction] LOG: statement: CREATE TABLE rounds_2021_11 PARTITION OF rounds FOR VALUES FROM (\u20182021-11-01 00:00:00\u2019) TO (\u20182021-12-01 00:00:00\u2019);<\/code><\/pre>\n<p>\u0425\u043c\u043c\u043c, \u0437\u0430\u0431\u0430\u0432\u043d\u043e, \u0432\u0435\u0434\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0438 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 (\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438) \u0443\u043f\u0430\u043b\u0438 \u0432 iddle in transaction. \u0427\u0442\u043e \u0436, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0433\u0440\u0435\u043f\u0430\u0442\u044c \u043b\u043e\u0433\u0438. <\/p>\n<pre><code>2021-10-25T00:00:00.080Z class=RoundPartitionsJob INFO: start   # ... \u043a\u0443\u0447\u043a\u0430 \u043b\u043e\u0433\u043e\u0432 2021-10-25T00:00:00.090Z DEBUG: (0.5ms)  BEGIN (0.3ms)   2021-10-25T00:00:00.093Z DEBUG: (0.3ms) SHOW statement_timeout;  2021-10-25T00:00:00.099Z DEBUG: (4.6ms) SET LOCAL statement_timeout = '0';  2021-10-25T00:00:00.184Z DEBUG: (86.4ms) CREATE TABLE rounds_2022_11 PARTITION OF rounds FOR VALUES FROM ('2021-11-01 00:00:00') TO ('2021-12-01 00:00:00');  2021-10-25T00:00:00.191Z DEBUG: (5.5ms) CREATE INDEX ... ON rounds_2021_11 ...;                                                    CREATE INDEX ... ON rounds_2021_11 ...;                                                    CREATE INDEX ... ON rounds_2021_11 ...;   2021-10-25T00:00:00.201Z ERROR: ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found. 2021-10-25T00:00:00.208Z DEBUG: (2.3ms) ROLLBACK # ... \u043a\u0443\u0447\u043a\u0430 \u043b\u043e\u0433\u043e\u0432<\/code><\/pre>\n<p>\u0410\u0433\u0430, \u0432\u043e\u0442 \u0432\u0438\u0436\u0443 \u043e\u0448\u0438\u0431\u043a\u0443, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043e\u043d\u0430 \u0441\u0430\u043c\u0430\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b\u0438 \u0441\u044b\u043f\u0430\u0442\u044c\u0441\u044f \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 2021-10-25T00:00:00.191Z. \u0412 \u0446\u0435\u043b\u043e\u043c ActiveRecord::ConnectionNotEstablished \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u043b\u044c\u0441\u0430 \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043d\u0435\u043a\u0442 \u0438\u0437 \u043f\u0443\u043b\u0430. \u041d\u041e \u041a\u0410\u041a? \u0412\u0435\u0434\u044c \u0432\u0438\u0434\u043d\u043e \u0436\u0435, \u0447\u0442\u043e \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e, \u043a\u043e\u043d\u0435\u043a\u0442 \u0431\u044b\u043b, \u043a\u0443\u0434\u0430 \u043e\u043d \u043c\u043e\u0433 \u043f\u0440\u043e\u043f\u0430\u0441\u0442\u044c?! \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0433\u0440\u0435\u043f\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435. \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0436\u043e\u0431\u044b \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0414\u0430\u043b\u0435\u0435 \u0438\u0437 \u043b\u043e\u0433\u043e\u0432 \u0431\u0430\u0437\u044b \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u044b\u0442\u0430\u044e\u0441\u0442\u044f \u0432\u0437\u044f\u0442\u044c \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043b\u043e\u043a \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 rounds \u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0443, \u0430 \u0442.\u043a. \u044d\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u044d\u0442\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0432\u0441\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0447\u0435\u0442\u043a\u043e \u0432\u0438\u0436\u0443 \u0440\u043e\u043b\u0431\u044d\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u043b\u044c\u0441\u0430 \u043f\u043e\u0441\u043b\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0431\u044b\u043b\u0430 \u0437\u0430\u0440\u0435\u0439\u0437\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043b\u043e\u043a\u043e\u0432 \u0431\u044b\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e. \u0418 \u0435\u0449\u0435 \u0432\u043e\u043f\u0440\u043e\u0441: \u0435\u0441\u043b\u0438 \u043d\u0435\u0442\u0443 \u043a\u043e\u043d\u0435\u043a\u0442\u0430, \u0442\u043e \u043a\u0443\u0434\u0430 \u043c\u044b \u043f\u043e\u0441\u043b\u0430\u043b\u0438 \u0440\u043e\u043b\u0431\u044d\u043a \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0439\u0447\u0430\u0441, \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0443\u0436\u0435 \u043f\u0430\u0440\u0443 \u043b\u0435\u0442? \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0439, \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0433\u0443\u0433\u043b\u0435\u0436\u0430 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u044b\u0441\u043b\u044c: \u0435\u0441\u043b\u0438 2 \u0434\u0436\u043e\u0431\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u0432 \u043e\u0434\u043d\u043e \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043a\u043e\u043d\u0435\u043a\u0442\u0430\u043c\u0438. \u0413\u0440\u0435\u043f\u0430\u0435\u043c \u0435\u0449\u0435 \u0440\u0430\u0437 \u0438 \u0431\u0438\u043d\u0433\u043e!<\/p>\n<pre><code>2021-10-25T00:00:00.162Z pid=106112 tid=7cdk class=UserBalanceChangesPartitionJob jid=ee3fe50224a09f0580880f97 INFO: start 2021-10-25T00:00:00.080Z pid=106112 tid=28ykc class=RoundPartitionsJob jid=7cc286bcc428205c53ec17e1 INFO: start<\/code><\/pre>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, pid&#8217;\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435. \u0423 \u043d\u0430\u0441 3 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u043e\u0432, \u043d\u0430 \u043a\u0430\u0436\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u043f\u043e 10 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441\u0430\u0439\u0434\u043a\u0438\u043a\u0430, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e 7 \u0442\u0440\u0435\u0434\u043e\u0432. \u0418 \u043d\u0430\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0447\u0442\u043e 2 \u043a\u0440\u043e\u043d \u0434\u0436\u043e\u0431\u043a\u0438 \u043f\u043e\u043f\u0430\u043b\u0438 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u0442\u0430\u043a\u0430\u044f (\u043e\u0434\u043d\u0430\u043a\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0435\u0449\u0435 \u0440\u0430\u0437 \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c): <\/p>\n<ol>\n<li>\n<p>\u0432 2021-10-25T00:00:00.080Z \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 RoundPartitionsJob, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0435\u043a\u0442 \u043f\u043e\u0434 migrations \u044e\u0437\u0435\u0440\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>RoundPartitionsJob \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442\u0443<\/p>\n<\/li>\n<li>\n<p>2021-10-25T00:00:00.162Z \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 UserBalanceChangesPartitionJob, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0435\u043a\u0442 \u043f\u043e\u0434 migrations \u044e\u0437\u0435\u0440\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0436\u0434\u0443 2021-10-25T00:00:00.162Z \u0438 2021-10-25T00:00:00.191Z \u0440\u0435\u043b\u044c\u0441\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0447\u0430\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u0442.\u043a. RoundPartitionsJob \u043d\u0435 \u0441\u043c\u043e\u0433 \u0432\u0437\u044f\u0442\u044c \u043a\u043e\u043d\u0435\u043a\u0442 \u0438\u0437 \u043f\u0443\u043b\u0430, \u0442\u043e UserBalanceChangesPartitionJob \u0443\u0436\u0435 \u043e\u0442\u0440\u0443\u0431\u0438\u043b \u0441\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u043d\u0435\u043a\u0442, \u043d\u043e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043b \u043d\u043e\u0432\u044b\u0439, RoundPartitionsJob \u043f\u0430\u0434\u0430\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0436\u0434\u0443 2021-10-25T00:00:00.191Z \u0438 2021-10-25T00:00:00.208Z UserBalanceChangesPartitionJob \u0443\u0436\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0430 \u043a\u043e\u043d\u0435\u043a\u0442, \u0440\u0435\u043b\u044c\u0441\u0430 \u0448\u043b\u0435\u0442 ROLLBACK \u043f\u043e\u0434 \u043d\u043e\u0432\u044b\u043c \u043a\u043e\u043d\u0435\u043a\u0442\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0442 \u0440\u043e\u043b\u0431\u044d\u043a \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0443\u0441\u0442\u043e\u0442\u0443, \u0442\u0430\u0431\u043b\u0438\u0446\u0430 rounds \u043d\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043b\u043e\u043a, \u0432\u0441\u0435 \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043a\u043e\u0434 \u0440\u0435\u043b\u044c\u0441\u044b \u0442\u043e \u043c\u043e\u044f \u0442\u0435\u043e\u0440\u0438\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"ruby\">def establish_connection(config)   resolver = ConnectionSpecification::Resolver.new(Base.configurations)   spec = resolver.spec(config)    remove_connection(spec.name) # \u0442\u0443\u0442 \u043a\u043e\u043d\u0435\u043a\u0442\u0430 \u043d\u0435\u0442\u0443    message_bus = ActiveSupport::Notifications.instrumenter   payload = {     connection_id: object_id   }   if spec     payload[:spec_name] = spec.name     payload[:config] = spec.config   end    # \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0443\u0442 \u043e\u043d \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f   message_bus.instrument(\"!connection.active_record\", payload) do     owner_to_pool[spec.name] = ConnectionAdapters::ConnectionPool.new(spec)   end    owner_to_pool[spec.name] end<\/code><\/pre>\n<p>\u041c\u0435\u0436\u0434\u0443 7\u0439 \u0438 17\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0440\u0435\u043b\u044c\u0441\u0430 \u0435\u0449\u0435 \u043d\u0435 \u0443\u0441\u043f\u0435\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0435\u043a\u0442 \u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0434\u043e\u0432 \u0442\u043e \u043c\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0435\u0437 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043a \u0431\u0430\u0437\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441: \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u043b\u044c\u0441\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 <code>remove_connection(spec.name)<\/code> \u043e\u043d\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 disconnect \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043e\u043d\u0435\u043a\u0442\u0435 \u0438 \u0442\u043e\u0433\u0434\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c \u0440\u043e\u043b\u0431\u044d\u0447\u043d\u0443\u0442\u0441\u044f. \u041a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e (\u0438\u043b\u0438 \u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e) \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 rounds \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043b\u043e\u0447\u0435\u043d\u043e\u0439, \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0437\u0430\u0433\u0430\u0434\u043a\u0430. \u041d\u043e \u0447\u0435\u0440\u0435\u0437 15 \u043c\u0438\u043d \u043b\u043e\u043a \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0441\u043d\u044f\u043b\u0441\u044f, \u0434\u0436\u043e\u0431\u0430 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0437\u0430\u0440\u0435\u0442\u0440\u0430\u0438\u043b\u0430\u0441\u044c \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e, \u0432\u0441\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b \u0443\u0448\u043b\u0438. <\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0430 \u043f\u043e\u0444\u0438\u043a\u0441\u0438\u0442\u044c \u0435\u0435 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0414\u043e Rails \u0432\u0435\u0440\u0441\u0438\u0438 6.0 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/gist.github.com\/mahemoff\/ca078e32f66a41fe6e9daad3512c6db4\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e<\/a> \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u043e \u0442.\u043a. \u043c\u044b \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/guides.rubyonrails.org\/active_record_multiple_databases.html\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0435\u043b\u044c\u0441\u044b<\/a> \u0438 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432 <\/p>\n<pre><code class=\"ruby\">ApplicationRecord.connected_to(role: :migration) do   # create partitions end<\/code><\/pre>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/587666\/\"> https:\/\/habr.com\/ru\/articles\/587666\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u0430\u043a \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u043c\u043d\u044e, \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a 25\u0435 \u043e\u043a\u0442\u044f\u0431\u0440\u044f, \u044f \u0437\u0430\u0441\u0442\u0443\u043f\u0430\u044e \u043d\u0430 \u0434\u0435\u0436\u0443\u0440\u0441\u0442\u0432\u043e \u043f\u043e \u043f\u0440\u043e\u0434\u0443 \u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0443\u0442\u0440\u0430 \u043c\u043d\u0435 \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430: \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432 \u043d\u043e\u0447\u044c \u0441 24 \u043d\u0430 25 \u043e\u043a\u0442\u044f\u0431\u0440\u044f, \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0413\u043b\u044f\u043d\u0443\u0432 \u0441\u0435\u043d\u0442\u0440\u0438 \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u043a\u0443\u0447\u0443 \u043e\u0448\u0438\u0431\u043e\u043a \u043e\u0442 \u0431\u0430\u0437\u044b \u0441\u043e statement timeout, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 <code>ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.<\/code> \u0421 \u043c\u044b\u0441\u043b\u044c\u044e &#171;\u0431\u0430\u0437\u0430 \u043d\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u043b\u0430, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u043d\u0430 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435&#187; \u044f \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043e\u0442\u0434\u0430\u043b \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0430\u0434\u043c\u0438\u043d\u0430\u043c, \u0430 \u0441\u0430\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0433\u043b\u044f\u043d\u0443\u043b \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043c \u0431\u044b\u043b \u0432\u0441\u043f\u043b\u0435\u0441\u043a \u043a\u0430\u043a\u0438\u0445-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0436\u043e\u0431\u043e\u043a \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043a\u0440\u0438\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u0433\u0440\u0430\u0444\u0430\u043d\u0435 \u043d\u0435\u0431\u044b\u043b\u043e: \u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u044b\u0445 \u0434\u0436\u043e\u0431\u043e\u043a \u0432 12 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u0430 \u0442\u0435, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e. <\/p>\n<p>\u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0432\u043e\u043d\u043e\u0447\u0435\u043a. \u0414\u043b\u044f \u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0432\u043e\u0434\u043d\u0443\u044e: \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0440\u0435\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414: \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u0441\u0430\u0439\u0434\u043a\u0438\u043a\u0430, \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u043b\u044f \u0430\u043f\u043f \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0442\u0440\u0435\u0442\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0443 \u043d\u0438\u0445 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f statement timeout&#8217;\u043e\u043c: \u0434\u043b\u044f \u0430\u043f\u043f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043e\u043d \u0441\u043e\u0432\u0441\u0435\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439, \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u043e\u0432 \u0447\u0443\u0442\u044c \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u0443 \u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043e\u043d \u0432\u043e\u0432\u0441\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u0422\u0430\u043a \u0432\u043e\u0442, \u0432 12 \u0447\u0430\u0441\u043e\u0432 \u043d\u043e\u0447\u0438 \u0440\u0435\u0437\u043a\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 \u044e\u0437\u0435\u0440\u043e\u043c migrations. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u042f \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b, \u0447\u0442\u043e \u0432 12 \u0447\u0430\u0441\u043e\u0432 \u0443 \u043d\u0430\u0441 \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u0434\u0436\u043e\u0431\u044b \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<pre><code class=\"yaml\">round_partitions_job:   cron: '0 0 25 * *'  # At 00:00 on day-of-month 25   class: RoundPartitionsJob processed_events_partitions_job:   cron: '0 0 25 * *'  # At 00:00 on day-of-month 25   class: ProcessedEventsPartitionsJob user_balance_changes_partition_job:   cron: '0 0 25 * *'  # At 00:00 on day-of-month 25   class: UserBalanceChangesPartitionJob <\/code><\/pre>\n<p>\u0425\u043c\u043c, \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u044d\u0442\u0438 \u0434\u0436\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u043f\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c migrations \u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438. \u041d\u043e \u044d\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0438\u043a\u0430\u043a \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b, \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432 \u0431\u044b\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u043e, \u043a\u0430\u043a \u043e\u043d\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<pre><code class=\"ruby\">Rails.root.join(\"config\", \"database.migrations.yml\")       .yield_self(&amp;File.method(:read))       .yield_self { |f| ERB.new(f).result }       .yield_self(&amp;YAML.method(:load))       .dig(Rails.env)       .yield_self(&amp;ActiveRecord::Base.method(:establish_connection))<\/code><\/pre>\n<p>\u0421\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0443 \u043d\u0430\u0441 \u0440\u0435\u0437\u043a\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u043a\u043e\u043b-\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 migrations \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u043b\u0438 ActiveRecord::Base.connection. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b \u0434\u0436\u043e\u0431\u043a\u0443 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434 \u0441\u0432\u043e\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434 migrations \u044e\u0437\u0435\u0440\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0437\u0430\u0442\u0443\u043f\u044b \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0439 \u043a\u043e\u0441\u044f\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u041d\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0441\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c: \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0438\u043b\u043e \u0442\u043e\u043b\u044c\u043a\u043e 15 \u043c\u0438\u043d\u0443\u0442, \u0430 \u043f\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0443 migrations \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u043f\u043e\u043b\u0443\u043d\u043e\u0447\u0438 \u0434\u043e 12 \u0434\u043d\u044f. \u0417\u043d\u0430\u0447\u0438\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432 \u044d\u0442\u043e\u043c. \u0418\u043b\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u043c, \u0434\u0443\u043c\u0430\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0432 \u043b\u043e\u0433\u0438 \u0431\u0430\u0437\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 rounds:<\/p>\n<pre><code class=\"sql\">[vxid:80\/29134748 txid:0] [idle in transaction] LOG: statement: CREATE TABLE rounds_2021_11 PARTITION OF rounds FOR VALUES FROM (\u20182021-11-01 00:00:00\u2019) TO (\u20182021-12-01 00:00:00\u2019);<\/code><\/pre>\n<p>\u0425\u043c\u043c\u043c, \u0437\u0430\u0431\u0430\u0432\u043d\u043e, \u0432\u0435\u0434\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0438 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 (\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438) \u0443\u043f\u0430\u043b\u0438 \u0432 iddle in transaction. \u0427\u0442\u043e \u0436, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0433\u0440\u0435\u043f\u0430\u0442\u044c \u043b\u043e\u0433\u0438. <\/p>\n<pre><code>2021-10-25T00:00:00.080Z class=RoundPartitionsJob INFO: start   # ... \u043a\u0443\u0447\u043a\u0430 \u043b\u043e\u0433\u043e\u0432 2021-10-25T00:00:00.090Z DEBUG: (0.5ms)  BEGIN (0.3ms)   2021-10-25T00:00:00.093Z DEBUG: (0.3ms) SHOW statement_timeout;  2021-10-25T00:00:00.099Z DEBUG: (4.6ms) SET LOCAL statement_timeout = '0';  2021-10-25T00:00:00.184Z DEBUG: (86.4ms) CREATE TABLE rounds_2022_11 PARTITION OF rounds FOR VALUES FROM ('2021-11-01 00:00:00') TO ('2021-12-01 00:00:00');  2021-10-25T00:00:00.191Z DEBUG: (5.5ms) CREATE INDEX ... ON rounds_2021_11 ...;                                                    CREATE INDEX ... ON rounds_2021_11 ...;                                                    CREATE INDEX ... ON rounds_2021_11 ...;   2021-10-25T00:00:00.201Z ERROR: ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found. 2021-10-25T00:00:00.208Z DEBUG: (2.3ms) ROLLBACK # ... \u043a\u0443\u0447\u043a\u0430 \u043b\u043e\u0433\u043e\u0432<\/code><\/pre>\n<p>\u0410\u0433\u0430, \u0432\u043e\u0442 \u0432\u0438\u0436\u0443 \u043e\u0448\u0438\u0431\u043a\u0443, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043e\u043d\u0430 \u0441\u0430\u043c\u0430\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b\u0438 \u0441\u044b\u043f\u0430\u0442\u044c\u0441\u044f \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 2021-10-25T00:00:00.191Z. \u0412 \u0446\u0435\u043b\u043e\u043c ActiveRecord::ConnectionNotEstablished \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u043b\u044c\u0441\u0430 \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043d\u0435\u043a\u0442 \u0438\u0437 \u043f\u0443\u043b\u0430. \u041d\u041e \u041a\u0410\u041a? \u0412\u0435\u0434\u044c \u0432\u0438\u0434\u043d\u043e \u0436\u0435, \u0447\u0442\u043e \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e, \u043a\u043e\u043d\u0435\u043a\u0442 \u0431\u044b\u043b, \u043a\u0443\u0434\u0430 \u043e\u043d \u043c\u043e\u0433 \u043f\u0440\u043e\u043f\u0430\u0441\u0442\u044c?! \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0433\u0440\u0435\u043f\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435. \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0436\u043e\u0431\u044b \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0414\u0430\u043b\u0435\u0435 \u0438\u0437 \u043b\u043e\u0433\u043e\u0432 \u0431\u0430\u0437\u044b \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u044b\u0442\u0430\u044e\u0441\u0442\u044f \u0432\u0437\u044f\u0442\u044c \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043b\u043e\u043a \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 rounds \u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0443, \u0430 \u0442.\u043a. \u044d\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u044d\u0442\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0432\u0441\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0447\u0435\u0442\u043a\u043e \u0432\u0438\u0436\u0443 \u0440\u043e\u043b\u0431\u044d\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u043b\u044c\u0441\u0430 \u043f\u043e\u0441\u043b\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0431\u044b\u043b\u0430 \u0437\u0430\u0440\u0435\u0439\u0437\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043b\u043e\u043a\u043e\u0432 \u0431\u044b\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e. \u0418 \u0435\u0449\u0435 \u0432\u043e\u043f\u0440\u043e\u0441: \u0435\u0441\u043b\u0438 \u043d\u0435\u0442\u0443 \u043a\u043e\u043d\u0435\u043a\u0442\u0430, \u0442\u043e \u043a\u0443\u0434\u0430 \u043c\u044b \u043f\u043e\u0441\u043b\u0430\u043b\u0438 \u0440\u043e\u043b\u0431\u044d\u043a \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0439\u0447\u0430\u0441, \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0443\u0436\u0435 \u043f\u0430\u0440\u0443 \u043b\u0435\u0442? \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0439, \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0433\u0443\u0433\u043b\u0435\u0436\u0430 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u044b\u0441\u043b\u044c: \u0435\u0441\u043b\u0438 2 \u0434\u0436\u043e\u0431\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u0432 \u043e\u0434\u043d\u043e \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043a\u043e\u043d\u0435\u043a\u0442\u0430\u043c\u0438. \u0413\u0440\u0435\u043f\u0430\u0435\u043c \u0435\u0449\u0435 \u0440\u0430\u0437 \u0438 \u0431\u0438\u043d\u0433\u043e!<\/p>\n<pre><code>2021-10-25T00:00:00.162Z pid=106112 tid=7cdk class=UserBalanceChangesPartitionJob jid=ee3fe50224a09f0580880f97 INFO: start 2021-10-25T00:00:00.080Z pid=106112 tid=28ykc class=RoundPartitionsJob jid=7cc286bcc428205c53ec17e1 INFO: start<\/code><\/pre>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, pid&#8217;\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435. \u0423 \u043d\u0430\u0441 3 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u043e\u0432, \u043d\u0430 \u043a\u0430\u0436\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u043f\u043e 10 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441\u0430\u0439\u0434\u043a\u0438\u043a\u0430, \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e 7 \u0442\u0440\u0435\u0434\u043e\u0432. \u0418 \u043d\u0430\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0447\u0442\u043e 2 \u043a\u0440\u043e\u043d \u0434\u0436\u043e\u0431\u043a\u0438 \u043f\u043e\u043f\u0430\u043b\u0438 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u0442\u0430\u043a\u0430\u044f (\u043e\u0434\u043d\u0430\u043a\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0435\u0449\u0435 \u0440\u0430\u0437 \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c): <\/p>\n<ol>\n<li>\n<p>\u0432 2021-10-25T00:00:00.080Z \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 RoundPartitionsJob, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0435\u043a\u0442 \u043f\u043e\u0434 migrations \u044e\u0437\u0435\u0440\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>RoundPartitionsJob \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442\u0443<\/p>\n<\/li>\n<li>\n<p>2021-10-25T00:00:00.162Z \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 UserBalanceChangesPartitionJob, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0435\u043a\u0442 \u043f\u043e\u0434 migrations \u044e\u0437\u0435\u0440\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0436\u0434\u0443 2021-10-25T00:00:00.162Z \u0438 2021-10-25T00:00:00.191Z \u0440\u0435\u043b\u044c\u0441\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0447\u0430\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u0442.\u043a. RoundPartitionsJob \u043d\u0435 \u0441\u043c\u043e\u0433 \u0432\u0437\u044f\u0442\u044c \u043a\u043e\u043d\u0435\u043a\u0442 \u0438\u0437 \u043f\u0443\u043b\u0430, \u0442\u043e UserBalanceChangesPartitionJob \u0443\u0436\u0435 \u043e\u0442\u0440\u0443\u0431\u0438\u043b \u0441\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u043d\u0435\u043a\u0442, \u043d\u043e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043b \u043d\u043e\u0432\u044b\u0439, RoundPartitionsJob \u043f\u0430\u0434\u0430\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u043c\u0435\u0436\u0434\u0443 2021-10-25T00:00:00.191Z \u0438 2021-10-25T00:00:00.208Z UserBalanceChangesPartitionJob \u0443\u0436\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0430 \u043a\u043e\u043d\u0435\u043a\u0442, \u0440\u0435\u043b\u044c\u0441\u0430 \u0448\u043b\u0435\u0442 ROLLBACK \u043f\u043e\u0434 \u043d\u043e\u0432\u044b\u043c \u043a\u043e\u043d\u0435\u043a\u0442\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0442 \u0440\u043e\u043b\u0431\u044d\u043a \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0443\u0441\u0442\u043e\u0442\u0443, \u0442\u0430\u0431\u043b\u0438\u0446\u0430 rounds \u043d\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043b\u043e\u043a, \u0432\u0441\u0435 \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043a\u043e\u0434 \u0440\u0435\u043b\u044c\u0441\u044b \u0442\u043e \u043c\u043e\u044f \u0442\u0435\u043e\u0440\u0438\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"ruby\">def establish_connection(config)   resolver = ConnectionSpecification::Resolver.new(Base.configurations)   spec = resolver.spec(config)    remove_connection(spec.name) # \u0442\u0443\u0442 \u043a\u043e\u043d\u0435\u043a\u0442\u0430 \u043d\u0435\u0442\u0443    message_bus = ActiveSupport::Notifications.instrumenter   payload = {     connection_id: object_id   }   if spec     payload[:spec_name] = spec.name     payload[:config] = spec.config   end    # \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0443\u0442 \u043e\u043d \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f   message_bus.instrument(\"!connection.active_record\", payload) do     owner_to_pool[spec.name] = ConnectionAdapters::ConnectionPool.new(spec)   end    owner_to_pool[spec.name] end<\/code><\/pre>\n<p>\u041c\u0435\u0436\u0434\u0443 7\u0439 \u0438 17\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0440\u0435\u043b\u044c\u0441\u0430 \u0435\u0449\u0435 \u043d\u0435 \u0443\u0441\u043f\u0435\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0435\u043a\u0442 \u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0434\u043e\u0432 \u0442\u043e \u043c\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0435\u0437 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043a \u0431\u0430\u0437\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441: \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u043b\u044c\u0441\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 <code>remove_connection(spec.name)<\/code> \u043e\u043d\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 disconnect \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043e\u043d\u0435\u043a\u0442\u0435 \u0438 \u0442\u043e\u0433\u0434\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c \u0440\u043e\u043b\u0431\u044d\u0447\u043d\u0443\u0442\u0441\u044f. \u041a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e (\u0438\u043b\u0438 \u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e) \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 rounds \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043b\u043e\u0447\u0435\u043d\u043e\u0439, \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0437\u0430\u0433\u0430\u0434\u043a\u0430. \u041d\u043e \u0447\u0435\u0440\u0435\u0437 15 \u043c\u0438\u043d \u043b\u043e\u043a \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0441\u043d\u044f\u043b\u0441\u044f, \u0434\u0436\u043e\u0431\u0430 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0437\u0430\u0440\u0435\u0442\u0440\u0430\u0438\u043b\u0430\u0441\u044c \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e, \u0432\u0441\u0435 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b \u0443\u0448\u043b\u0438. <\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0430 \u043f\u043e\u0444\u0438\u043a\u0441\u0438\u0442\u044c \u0435\u0435 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0414\u043e Rails \u0432\u0435\u0440\u0441\u0438\u0438 6.0 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/gist.github.com\/mahemoff\/ca078e32f66a41fe6e9daad3512c6db4\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e<\/a> \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u043e \u0442.\u043a. \u043c\u044b \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/guides.rubyonrails.org\/active_record_multiple_databases.html\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0435\u043b\u044c\u0441\u044b<\/a> \u0438 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432 <\/p>\n<pre><code class=\"ruby\">ApplicationRecord.connected_to(role: :migration) do   # create partitions end<\/code><\/pre>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/587666\/\"> https:\/\/habr.com\/ru\/articles\/587666\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-390484","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/390484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=390484"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/390484\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=390484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=390484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=390484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}