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

Threading bug on the /~user/threads page #1236

Open
jmiven opened this issue Jan 2, 2024 · 1 comment
Open

Threading bug on the /~user/threads page #1236

jmiven opened this issue Jan 2, 2024 · 1 comment

Comments

@jmiven
Copy link

jmiven commented Jan 2, 2024

On my threads page, a 3 days old comment on a story is threaded under a more recent comment on another story.

threading_bug
@pushcx
Copy link
Member

pushcx commented Feb 14, 2024

Well, this is the result of my big clever redesign of the threading code in #1190. I saw this bug and hoped I could override the parent_depth test in app/views/comments/_threads.html.erb by comparing thread_id, but with @lonjil’s report of #1251 it’s clear this is a more general problem. In that one, like here, the comments are in the wrong place because the parent comments have identical votes (~half of comments have one or two upvotes and zero flags) and the low byte of their id is identical. (We get ~200 comments per day, note that in both reports’ screenshots the parents are posted 2 days apart.)

This is going to be some amount of redesign to the confidence_order field and Comment#update_score_and_recalculate! for a reliable fix. I had considered that siblings might swap order a bit (see comment) but I didn’t realize that I was setting up a 1 in 256 chance that they’d swap children because of it.

An obvious fix would be to increase the comment id component of confidence_order to two bytes. It would seem that it reduces the chances from 1 in 256 to 1 in 65,536. However! We get ~200 comments per day and stories accept comments for 90 days (Story::COMMENTABLE_DAYS), so we only see ~18,000 comment IDs in the period available for a collision.

That works in practice but not in theory. I don’t love that it would set up an ever rarer bug if we grow. I have a hunch there’s a better fix available that I’m not immediately seeing, one that doesn’t increase the width of confidence_order_path. Maybe it’ll come to me, or maybe someone else has an idea for a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants