KX style second SQL-encapsulated increment column for board id #22
ctrlcctrlv
commented
May 12, 2015
jaw-sh
commented
May 31, 2015
Concurrency testing indicates that the database is now able to properly deal with many posts at one time using transactions.
ctrlcctrlv
commented
Jun 1, 2015
Yup, I wrote a quick flooder by disabling CAPTCHA and CSRF token and then bombing it with posts from one hundred threads. I got up to 30 posts/second and no rejections/errors. Nice one.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Much to @jaw-sh's disapopintment, it is a definite requirement to have a board_id that autoincrements along with a global ID that auto increments.
Kusaba X, one of the original chan engine and the one that Tinyboard rewrote provides us with this schema:
Psql supports it as well. SQLite does with a CREATE TRIGGER. Unfortuantely, in MySQL in only one engine InnoDB this is impossible.
Looping forever like (psuedocode):
while ($error && $error->isDuplicateIdError) try_again();hits the database far too often and is assuredly bad practice. In very active threads this could potentially loop ten times with a busy DB. I've done tests before of this on live software for a project and it was a disaster, but it 'worked' and I got paid. Let's try to do better than just get paid and do a good job as well.
We cannot just use global IDs and we cannot just use IDs based on position in the thread (>>1, >>2 etc) due to familiarity reasons. We need to keep this hack from KX, without just devolving into a million post tables like Tinyboard/vichan/infinity stable. I will write a migration for it.