mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-04 15:43:16 -06:00
[feature] Prune timelines once per hour to plug memory leak (#1117)
* export highest/lowest ULIDs as proper const * add stop + start to timeline manager, other small fixes * unexport unused interface funcs + tidy up * add LastGot func * add timeline Prune function * test prune * update lastGot
This commit is contained in:
parent
90bbcf1bcf
commit
50dc179d33
16 changed files with 594 additions and 602 deletions
|
|
@ -69,63 +69,6 @@ func (suite *IndexTestSuite) TearDownTest() {
|
|||
testrig.StandardDBTeardown(suite.db)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestIndexBeforeLowID() {
|
||||
// index 10 before the lowest status ID possible
|
||||
err := suite.timeline.IndexBefore(context.Background(), "00000000000000000000000000", 10)
|
||||
suite.NoError(err)
|
||||
|
||||
postID, err := suite.timeline.OldestIndexedItemID(context.Background())
|
||||
suite.NoError(err)
|
||||
suite.Equal("01F8MHBQCBTDKN6X5VHGMMN4MA", postID)
|
||||
|
||||
indexLength := suite.timeline.ItemIndexLength(context.Background())
|
||||
suite.Equal(10, indexLength)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestIndexBeforeHighID() {
|
||||
// index 10 before the highest status ID possible
|
||||
err := suite.timeline.IndexBefore(context.Background(), "ZZZZZZZZZZZZZZZZZZZZZZZZZZ", 10)
|
||||
suite.NoError(err)
|
||||
|
||||
// the oldest indexed post should be empty
|
||||
postID, err := suite.timeline.OldestIndexedItemID(context.Background())
|
||||
suite.NoError(err)
|
||||
suite.Empty(postID)
|
||||
|
||||
// indexLength should be 0
|
||||
indexLength := suite.timeline.ItemIndexLength(context.Background())
|
||||
suite.Equal(0, indexLength)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestIndexBehindHighID() {
|
||||
// index 10 behind the highest status ID possible
|
||||
err := suite.timeline.IndexBehind(context.Background(), "ZZZZZZZZZZZZZZZZZZZZZZZZZZ", 10)
|
||||
suite.NoError(err)
|
||||
|
||||
// the newest indexed post should be the highest one we have in our testrig
|
||||
postID, err := suite.timeline.NewestIndexedItemID(context.Background())
|
||||
suite.NoError(err)
|
||||
suite.Equal("01G36SF3V6Y6V5BF9P4R7PQG7G", postID)
|
||||
|
||||
indexLength := suite.timeline.ItemIndexLength(context.Background())
|
||||
suite.Equal(10, indexLength)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestIndexBehindLowID() {
|
||||
// index 10 behind the lowest status ID possible
|
||||
err := suite.timeline.IndexBehind(context.Background(), "00000000000000000000000000", 10)
|
||||
suite.NoError(err)
|
||||
|
||||
// the newest indexed post should be empty
|
||||
postID, err := suite.timeline.NewestIndexedItemID(context.Background())
|
||||
suite.NoError(err)
|
||||
suite.Empty(postID)
|
||||
|
||||
// indexLength should be 0
|
||||
indexLength := suite.timeline.ItemIndexLength(context.Background())
|
||||
suite.Equal(0, indexLength)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestOldestIndexedItemIDEmpty() {
|
||||
// the oldest indexed post should be an empty string since there's nothing indexed yet
|
||||
postID, err := suite.timeline.OldestIndexedItemID(context.Background())
|
||||
|
|
@ -137,17 +80,6 @@ func (suite *IndexTestSuite) TestOldestIndexedItemIDEmpty() {
|
|||
suite.Equal(0, indexLength)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestNewestIndexedItemIDEmpty() {
|
||||
// the newest indexed post should be an empty string since there's nothing indexed yet
|
||||
postID, err := suite.timeline.NewestIndexedItemID(context.Background())
|
||||
suite.NoError(err)
|
||||
suite.Empty(postID)
|
||||
|
||||
// indexLength should be 0
|
||||
indexLength := suite.timeline.ItemIndexLength(context.Background())
|
||||
suite.Equal(0, indexLength)
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TestIndexAlreadyIndexed() {
|
||||
testStatus := suite.testStatuses["local_account_1_status_1"]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue