'Why does Rails hang when converting an ActiveRecord Collection with a single record to an array with #first?

I have the following AR statement in a Rails 5.2.3 application:

listings = subscription.listings.limit(1)

An AR collection containing a single object is immediately returned.

However... and this is very strange, the following statement:

listings.first

Immediately spikes the CPU usage to 100%, and the process must be manually killed. Not even Ctrl-C fixes it. It has to be killed from the command line.

What could be happening here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source