Skip to content

Backport #40527 and #40626 to 6-1-stable#40729

Merged
rafaelfranca merged 2 commits intorails:6-1-stablefrom
jonathanhefner:backport-40527-and-40626
Dec 2, 2020
Merged

Backport #40527 and #40626 to 6-1-stable#40729
rafaelfranca merged 2 commits intorails:6-1-stablefrom
jonathanhefner:backport-40527-and-40626

Conversation

@jonathanhefner
Copy link
Member

These were missing from 6.1.0.rc2 (see #40527 (comment) and #40626 (comment)).

Follow-up to rails#39746.

This shifts the responsibility of loading Spring from `config/boot.rb`
back to the relevant bin files.

Fixes rails#40518.
Closes rails#40521.

(cherry picked from commit acc837e)
Before rails#34953, when using the `:async` Active Job queue adapter, jobs
enqueued in `db/seeds.rb`, such as Active Storage analysis jobs, would
cause a hang (see rails#34939).  Therefore, rails#34953 changed all jobs enqueued
in `db/seeds.rb` to use the `:inline` queue adapter instead.  (This
behavior was later limited to only take effect when the `:async` adapter
was configured, see rails#35905.)  However, inline jobs in `db/seeds.rb`
cleared `CurrentAttributes` values (see rails#37526).  Therefore, rails#37568
changed the `:inline` adapter to wrap each job in its own thread, for
isolation.  However, wrapping a job in its own thread affects which
database connection it uses.  Thus inline jobs can no longer execute
within the calling thread's database transaction, including seeing any
uncommitted changes.  Additionally, if the calling thread is not wrapped
with the executor, the inline job thread (which is wrapped with the
executor) can deadlock on the load interlock.  And when testing (with
`connection_pool.lock_thread = true`), the inline job thread can
deadlock on one of the locks added by rails#28083.

Therefore, this commit reverts the solutions of rails#34953 and rails#37568, and
instead wraps evaluation of `db/seeds.rb` with the executor.  This
eliminates the original hang from rails#34939, which was also due to running
multiple threads and not wrapping all of them with the executor.  And,
because nested calls to `executor.wrap` are ignored, any inline jobs in
`db/seeds.rb` will not clear `CurrentAttributes` values.

Alternative fix for rails#34939.
Reverts rails#34953.
Reverts rails#35905.
Partially reverts rails#35896.

Alternative fix for rails#37526.
Reverts rails#37568.

Fixes rails#40552.

(cherry picked from commit 648da12)
@rafaelfranca
Copy link
Member

How did I miss that? Thank you.

@rafaelfranca rafaelfranca merged commit ad8027f into rails:6-1-stable Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants