User "Catrope" posted a comment on MediaWiki.r96722.

Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96722#c22308
Commit summary:

Epic followup to r94404, r94509: change the ArticleFeedback schema such that 
locking is no longer necessary. This should fix the counter drift problems, 
too. Thanks to Tim for pointing me in this direction.

* Change the schema of article_feedback to no longer have a primary key that 
ensures one rating per user per revision, but to have a primary key on the 
auto-incremented field aa_id instead
** This allows multiple ratings per user per revision in the article_feedback 
table, which makes the counter drift fix possible
** This schema change is so radical that the patch has to create another table 
with the new schema, copy the data over, and swap the tables
* Changed ApiArticleFeedback::insertUserRatings() to insert all the ratings 
rows at once, using one query. This ensures they get consecutive aa_id values
* Moved the SELECT in ApiArticleFeedback after the insertUserRatings() call, 
and added an "aa_id < $id" clause so it always looks at the rating set right 
before the one that was just inserted, even if another thread has already 
inserted another rating set in the meantime. This ensures that each rating 
delta is handled by exactly one thread, which should fix counter drift.
* Removed the useless and broken behavior of decrementing values in 
article_feedback_revisions. It was implemented inconsistently and never worked 
properly for that reason. This makes insertRevisionRating() much simpler
* Due to the insertRevisionRating() change. $lastRevision is no longer needed. 
To properly update the revision delta, though, we still need to look at whether 
the previous rating's revid matches this one's, and only take that rating into 
account if it does. The previous logic was probably broken and, now that I 
think about it, was probably the cause of all the weird behavior, but it's too 
late to go back now. I'll patch 1.17wmf1 for just this problem later, see if 
that helps
* Take this opportunity to redo the indexes on article_feedback so the queries 
run on it are actually indexed properly. Also drop useless aa_user_id 
conditions from queries.

Comment:

Looks like 1.17wmf1 would be mostly fixed with just these few lines: 
https://gist.github.com/1208442

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to