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 500 server error on project dashboard #1779

Merged
merged 2 commits into from
Sep 28, 2023
Merged

Conversation

rmunn
Copy link
Collaborator

@rmunn rmunn commented Sep 25, 2023

Description

Large projects were returning an HTTP 500 on the project dashboard, because PHP was running out of memory trying to return every entry for stats to be calculated client-side. This changes the stats to be calculated server-side instead. We get rid of the "number of entries with audio" stat because it's not possible to calculate in a simple Mongo query and would require serializing the entire entry database server-side, causing the very memory error we're trying to get rid of.

Fixes #1773.
Fixes #1775.

Checklist

  • I have labeled my PR with: bug, feature, engineering, security fix or testing
  • I have performed a self-review of my own code
  • I have reviewed the title & description of this PR which I will use as the squashed PR commit message
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have enabled auto-merge (optional)

Testing

  • Load a large project (via Send/Receive) into Language Forge
  • In that project, click on the project name in "My Projects -> (project name)" in the upper left

If the bug is not fixed, you'll get a 500 Internal Server Error page. If the bug is fixed, you'll get the dashboard.

Large projects were returning an HTTP 500 on the project dashboard,
because PHP was running out of memory trying to return every entry for
stats to be calculated client-side. This changes the stats to be
calculated server-side instead. We get rid of the "number of entries
with audio" stat because it's not possible to calculate in a simple
Mongo query and would require serializing the entire entry database
server-side, causing the very memory error we're trying to get rid of.
@rmunn rmunn added the bug An existing problem with our app in production label Sep 25, 2023
@github-actions
Copy link

github-actions bot commented Sep 25, 2023

Unit Test Results

362 tests   362 ✔️  16s ⏱️
  37 suites      0 💤
    1 files        0

Results for commit 0e6e7a8.

♻️ This comment has been updated with latest results.

@rmunn rmunn requested a review from hahn-kev September 25, 2023 09:36
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

Looks good to me, just one minor suggestion as it seems weird to me to open a connection 3 times for 3 queries happening one after another.

src/Api/Model/Shared/Mapper/MongoQueries.php Outdated Show resolved Hide resolved
Now the lex_stats call opens a single MongoDB connection and reuses it
for all three queries. The efficiency boost might be minor, but it's
also a slight code simplification so it's just as well to do it now.
@rmunn rmunn merged commit 4869afc into develop Sep 28, 2023
16 of 17 checks passed
@rmunn rmunn deleted the bugfix/dashboard-500 branch September 28, 2023 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An existing problem with our app in production
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: PHP lex_stats call shouldn't return entire entries list Viewing project page throws a 500
2 participants