-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Refactor thread fetching into an iterative operation #538
Comments
I think the ideal handling of threads is to use an asynchronous job worker like Mastodon's Maybe this would require the database schema to be aware of replies whose |
Yeah, good point. But even if it's run in a background task, I'd personally prefer an iterative operation since it won't exhaust the stack space because of function calls |
Not sure if we need that. We could just set that to |
I was assuming that the worker would only fetch a single post in a job and, well, recursively enqueue another job to the scheduler to fetch the reply until the thread is fully resolved, so that it won't exhaust the stack (and each job is reasonably short-lived). That's how Mastodon's worker is implemented IIUC.
Yes, I think we don't need this if we can hold a transaction over the whole thread resolution process, but otherwise, clients may observe a reply whose in_reply_to post haven't been resolved. Just making the Well, come to think of it, we don't keep a transaction over the whole |
To be fair, the whole ActivityPub fetching logic with the database mapping needs a major cleanup. It's in an abysmal state at the moment. Maybe that cleanup can also add better testing to it finally. |
Is your feature request related to a problem? Please describe.
Right now thread fetching is a recursive operation and overflows the stack quite quickly. We already introduced the recursion limit but it already overflows when only fetching 10 replies.
This isn't ideal.
Describe the solution you'd like
Technically every recursive algorithm can be rewritten as an iterative one and vice versa. This is what we need to do here. Make the thread fetching iterative instead.
The text was updated successfully, but these errors were encountered: