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

Incomplete ranks shown while CAD is running #9569

Closed
jonatanklosko opened this issue Jun 22, 2024 · 4 comments
Closed

Incomplete ranks shown while CAD is running #9569

jonatanklosko opened this issue Jun 22, 2024 · 4 comments
Labels
SERVICE: results Anything pertaining to how results are stored or displayed TYPE: bug Bug reported by a stakeholder

Comments

@jonatanklosko
Copy link
Member

We have the manually-triggered background job for computing ranks information (CAD). For each of the ranks tables, it removes all rows, then computes and inserts fresh rows. While the computation is running, the ranks tables have missing information, which surfaces in the UI and API.

Here are a few screenshots while running CAD on the staging, where it can be seen how CAD progresses:

Screenshots
  • Records showing only average as ConciseSingleResults are being computed
    image
  • Records showing only single as ConciseAverageResults are being computed
    image
  • Incremental entries in the profile as RanksSingle are being computed
    image
    image

The same issue affects API endpoints that rely on ranks (records, WCIF personal bests), and that is a bigger problem, because API users definitely don't expect records to suddenly have no entries.

For more context, I believe this is the underlying issue behind a few strange false-positive record tags we've seen on WCA Live thewca/wca-live#145.

Note that some of the pages/endpoints are cached, so keep that in mind when reproducing.

@dunkOnIT dunkOnIT added TYPE: bug Bug reported by a stakeholder SERVICE: results Anything pertaining to how results are stored or displayed labels Jun 24, 2024
@gregorbg
Copy link
Member

Interesting... Taking a complete shot in the dark here but would wrapping the whole CAD process into a transaction help?

@jonatanklosko
Copy link
Member Author

We already update each table in a transaction, so it should be atomic:

ActiveRecord::Base.transaction do
ActiveRecord::Base.connection.execute "DELETE FROM #{table_name}"
ActiveRecord::Base.connection.execute "ALTER TABLE #{table_name} AUTO_INCREMENT = 1"
ActiveRecord::Base.connection.execute <<-SQL
INSERT INTO #{table_name} (id, #{field}, valueAndId, personId, eventId, countryId, continentId, year, month, day)

Just looking at the code I don't have any reasonable idea, unless the queries skip the transaction somehow. One option to test would be to add rollback after the delete and see if that works as expected.

@dunkOnIT
Copy link
Contributor

dunkOnIT commented Aug 5, 2024

#9742 is an example of a fix for this issue which would help us determine if the issue is indeed the in-progress table being read while CAD is running.

The other approach was to increase the isolation level of the CAD transactions, but that seems like a very bad idea because it can lead to database locks etc.

@jonatanklosko
Copy link
Member Author

I believe we can close this now, thanks @dunkOnIT :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SERVICE: results Anything pertaining to how results are stored or displayed TYPE: bug Bug reported by a stakeholder
Projects
None yet
Development

No branches or pull requests

3 participants