Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in active record cursor #69

Merged
merged 1 commit into from
Mar 30, 2021

Conversation

pedropb
Copy link
Contributor

@pedropb pedropb commented Mar 18, 2021

This commit patches the active record cursor implementation so that the
queries emitted by relation.to_a in next_batch are never cached.
This makes sense because it is a waste to cache results of queries like
SELECT ... WHERE id > ... LIMIT ... in an enumerator that is only
moving forward.

The uncached interface I make use of in this commit was introduced by
rails/rails#28867 under a similar context.

@pedropb pedropb changed the base branch from master to fix-rubocop March 18, 2021 17:01
@pedropb pedropb changed the base branch from fix-rubocop to master March 18, 2021 17:01
@pedropb pedropb marked this pull request as ready for review March 24, 2021 13:27
@pedropb pedropb force-pushed the fix-memory-leak-in-AR-cursor-next-batch branch from 218309e to 84218c4 Compare March 29, 2021 13:57
This commit patches the active record cursor implementation so that the
queries emitted by `relation.to_a` in `next_batch` are never cached.
This makes sense because it is a waste to cache results of queries like
`SELECT ... WHERE id > ... LIMIT ...` in an enumerator that is only
moving forward.

The `uncached` interface I make use of in this commit was introduced by
rails/rails#28867 under a similar context.
@GustavoCaso GustavoCaso force-pushed the fix-memory-leak-in-AR-cursor-next-batch branch from 84218c4 to 342df24 Compare March 29, 2021 14:22
@pedropb pedropb merged commit f752c66 into master Mar 30, 2021
@pedropb pedropb deleted the fix-memory-leak-in-AR-cursor-next-batch branch March 30, 2021 13:48
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems March 30, 2021 13:50 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants