fix broken timelines #102
Loading…
Reference in a new issue
No description provided.
Delete branch "missing-timeline"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
handle note visibility in SQL
This allows to check visibility recursively, which should hopefully solve #70 because the visibility is checked properly.
WIP: fix broken timelinesto fix broken timelinesThink I mentioned it in IRC a few times, but this does seem to cause a lot more timeouts especially on user profiles and doing searches.
Wondering if memoizing the recursive results somehow would help with performance...
For the search I think the problem is that the visibility query is being applied at the same time as the actual search. If we could instead first do the search and then apply the visibility query only to the limited result of that I think we should see a significant performance improvement.
Perhaps similar for the user profiles: First select the posts, then apply the visibility query.
In general it might be a good idea to refactor
generateVisibilityQuery
to somehow run the "main" query as a subselect and then apply the visibility query, although I'm not sure if or how that is possible in TypeORM.From what I can tell, you'd make another query builder for the subquery, then use the
getQuery()
method to get the generated SQL and use that in the main query builder in place of a table: https://typeorm.io/select-query-builder#using-subqueriesI don't think that works here because what I wanted to do in SQL is something like e.g.
I.e. select stuff not from the notes table itself but from the subquery. The example you linked does not do that, it
innerJoin
s the subquery.Apparently query builders have a
from
method where you can also make use of subqueries, see https://typeorm.io/select-query-builder#using-subqueries. However, both of the examples that use the "from subquery" functionality also usegetRawMany
at the end. Would have to test ifgetMany
(i.e. not raw) would also work.fd5b46c65a
to8a90dfa60b
Now rewritten to do it in two stages. By testing it at least seems to not completely break. Question is of course if it still has performance problems. Can you test again?
Seems to work now. No performance issues as far as I can tell.
Timeline still stops loading after a certain point, nvm.
Can you check in the networking tab how many notes were in the last API response for the timeline endpoint?
From the last
timeline
response:Hmm, now I'm even more confused than before. I think that means at least this problem is fixed because the number of notes returned is as intended.
But there is apparently another bug in the client somewhere? 🥴 No idea.
It looks like though that previous responses from the timeline endpoint have 31 notes.
Seems like somewhere the server doesn't send the extra note that the client requests and therefore the client thinks there's nothing left to fetch.
Ah right, it should be 31, so it's apparently still the same issue. My bad.
Not sure if my random input will be of any value, but here are some things:
I hope my wording won't be too tangled.
Right now a new user on my instance created an account and only followed another user who had only 2 posts to show on the Home timeline. So the timeline wouldn't load at all from the start, the request for getting 11 posts as the timeline page is loaded would return 500.
I created a test account myself to poke around and indeed I could reproduce their issue. Resending the request with
limit: 2
instead of 11 will succeed. So it seems it fails if the limit is higher than the posts it has to show. But I am not sure if this is a separate different issue from this.But then I also followed only my backup alt account. The request for the top of the timeline (with
limit: 11
) worked. but, scrolling down, the next request for the continuation of the timeline (with{"limit":31,"untilId":"96qo2d643g"}
in the body) would time out. But if I sent this same request with limit: 10 it would succeed to respond... 11 and higher would fail.I mentioned it is my backup account because populating the timeline with only my main one would make the timeline work fine. Now what difference between the two would make the difference? I don't know. The backup is a remote account with posts further between each other chronologically, since I post rarer there, while my main account is local and more dense in posts.
I didn't get to look into what happens exactly on the server side, with debug logs, but I can try that.
I couldn't reproduce this on a testing instance, so if you could check if there are any log entries related to this would be good. Although I suspect it might be a database timeout for one reason or another.
(Sorry I came back so late)
Yes it's because of a database timeout, many queries on it are slow and I'm trying to troubleshoot that.
But either way I think my problem is unrelated to the original issue of this thread. Which, to add, doesn't occur on 3rd party clients like Kaiteki while on the web client it would. So it may be related to the client.
I could open a new issue about the queries that are slow and timing out for me and look deeper into it
8a90dfa60b
tod7d10ccd60
23f811ec48
toaece832c86