Rails ActiveRecordで失敗したクエリのリトライ
7.1からallow_retryオプションがinternal APIに追加された
7.2からArel経由でbuildされたSELECTや、既知のattributesに対するfind, find_byは自動でリトライされるようになった
* SELECT queries we construct by walking the Arel tree via #to_sql_and_binds. We use a new retryable attribute on collector classes, which defaults to true for most node types, but will be set to false for non-idempotent node types (functions, SQL literals, update / delete / insert statements, etc). The retryable value is returned from #to_sql_and_binds and used by #select_all and passed down the call stack, eventually reaching the adapter's #internal_exec_query method.
> * #find and #find_by queries with known attributes. We set allow_retry: true in #cached_find_by, and pass this down to #find_by_sql and #_query_by_sql.
関連