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

Add setting for sort and limit #22

Merged
merged 1 commit into from
Oct 11, 2018
Merged

Conversation

jasperzeinstra
Copy link
Contributor

It would be nice of you could set a limit of jobs to process at one time. Now we run in to the problem that many new jobs are added at the same time and we're hitting a memory limit when all these jobs need to be handle in one go.

We would also like to have the possibility to run the jobs in the first in first out order instead of random.

I added two settings to manage this functionality.

$collection->getSelect()->order(new Zend_Db_Expr('RAND()'));
if (Mage::getStoreConfigFlag('jobqueue/config/sort_random')) {
// randomly order to prevent lock contention among workers
$collection->getSelect()->order(new Zend_Db_Expr('RAND()'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this was added, it doesn't really have any benefit. Can you just remove and sort the collection by ascending ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the comment says: randomly order to prevent lock contention among workers. With the added system config setting it's now configurable. That's more backwards compatible then just removing it.

@jkowens jkowens merged commit 8d34279 into jkowens:master Oct 11, 2018
@jkowens
Copy link
Owner

jkowens commented Oct 11, 2018

Thanks for your contribution! 💯

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.

None yet

2 participants