2014-07-31, 01:13 PM
(This post was last modified: 2014-07-31, 01:17 PM by SalamanderBSC.)
Currently the forum will store and use a list of all poll votes and the counts for each option in the DB.
This essentially amounts to "look up the previous stored count of votes, increment by one, store back in database"
This is susceptible to a race condition when two or more people vote at the same time.
E.G. for a two-option poll with options Cats and Dogs
Bob: looks up the count of poll votes, it reads Cats=0, Dogs=0 from the database
Bob: selected Cats, so it sets Cats=1, Dogs=0
Jane: looks up the count of poll votes, it reads Cats=0, Dogs=0 from the database
Bob: saves Cats=1, Dogs=0 in the database
Jane: selected Dogs, so it sets Cats=0, Dogs=1
Jane: saves Cats=0, Dogs=1 in the database
Now the poll has two votes, but the counts for Cats=0 and Dogs=1
I will attempt to recreate it here with a little luck.
EDIT:
First shot, score.
This essentially amounts to "look up the previous stored count of votes, increment by one, store back in database"
This is susceptible to a race condition when two or more people vote at the same time.
E.G. for a two-option poll with options Cats and Dogs
Bob: looks up the count of poll votes, it reads Cats=0, Dogs=0 from the database
Bob: selected Cats, so it sets Cats=1, Dogs=0
Jane: looks up the count of poll votes, it reads Cats=0, Dogs=0 from the database
Bob: saves Cats=1, Dogs=0 in the database
Jane: selected Dogs, so it sets Cats=0, Dogs=1
Jane: saves Cats=0, Dogs=1 in the database
Now the poll has two votes, but the counts for Cats=0 and Dogs=1
I will attempt to recreate it here with a little luck.
EDIT:
First shot, score.