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: Limits the events processed in the cron to avoid overflows and timeouts. #203

Merged
merged 6 commits into from
Aug 1, 2018

Conversation

AndyHubert
Copy link
Contributor

If the backlog in the logstore_xapi_log gets too long, then the call to get_records can either time out or runs out of memory.

Copy link
Member

@ryasmi ryasmi left a comment

Choose a reason for hiding this comment

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

Hey @AndyHubert, thanks for this, really appreciate it. Just one change to request.

@@ -39,7 +39,7 @@ public function execute() {
global $DB;
$manager = get_log_manager();
$store = new store($manager);
$extractedevents = $DB->get_records('logstore_xapi_log');
$extractedevents = $DB->get_records('logstore_xapi_log', null, '', '*', 0, $store->get_max_batch_size());
Copy link
Member

Choose a reason for hiding this comment

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

Hey @AndyHubert, could you please extract these other arguments (null, '', '*', and 0) into variables so it's a little more obvious what they mean? For example the '*' might be defined as $selectedfields = '*' or something along those lines.

@ryasmi ryasmi changed the title Limit the get_records query to max batch size fix: Limits the events processed in the cron to avoid overflows and timeouts. Jul 31, 2018
@@ -108,7 +112,7 @@ public function process_events(array $events) {
'lrs_endpoint' => $this->get_config('endpoint', ''),
'lrs_username' => $this->get_config('username', ''),
'lrs_password' => $this->get_config('password', ''),
'lrs_max_batch_size' => $this->get_config('maxbatchsize', 100),
'lrs_max_batch_size' => $this->get_max_batch_size(),
Copy link
Contributor

@caperneoignis caperneoignis Jul 31, 2018

Choose a reason for hiding this comment

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

Real quick, do these event's get processed from oldest to newest or newest to oldest? Because if it's newest to oldest, the batch size could be small enough, that we start to get a backlog in bigger systems, under heavier usage. So we end up with events, never getting sent, because the amount of new events is greater then the batch size per cron run. Especially with systems seeing 1k users worth of traffic. Just a curious question.

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the code, I believe it would be oldest to newest. I'm going to merge this and we can resolve that issue separately when needed.

@ryasmi ryasmi added the fix label Aug 1, 2018
@ryasmi
Copy link
Member

ryasmi commented Aug 1, 2018

Thanks for adding those variables @AndyHubert, much easier to read that bit now 👍

@ryasmi ryasmi merged commit c680b0c into xAPI-vle:master Aug 1, 2018
@HT2Bot
Copy link
Member

HT2Bot commented Aug 1, 2018

🎉 This PR is included in version 3.9.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants