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

Truncate tables and rename documents folder on reset #5918

Merged
merged 3 commits into from
Jun 17, 2024
Merged

Conversation

mejo-
Copy link
Member

@mejo- mejo- commented Jun 17, 2024

📝 Summary

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits

Copy link
Member

@juliushaertl juliushaertl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 For the truncate part, would appreciate a review for my first commit then

@mejo- mejo- changed the title Truncate tables and remove documents folder on reset Truncate tables and rename documents folder on reset Jun 17, 2024
$fileIds = array_map(static function (Document $document) {
return $document->getId();
}, $this->documentService->getAll());
$fileIds = $this->documentService->getAll();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliushaertl I don't understand this change. DocumentService->getAll() returns an array of Document objects, not the file IDs. How is this supposed to work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and indeed it broke with your current approach. The old approach didn't work either as array_map() cannot be run against a Generator. I pushed a fix:

$fileIds = [];
$documents = $this->documentService->getAll();
foreach ($documents as $document) {
	$fileIds[] = $document->getId();
}

@mejo- mejo- force-pushed the fix/reset_sessions branch 3 times, most recently from 29cd087 to fe9a94f Compare June 17, 2024 14:37
Signed-off-by: Julius Härtl <jus@bitgrid.net>
@mejo-
Copy link
Member Author

mejo- commented Jun 17, 2024

would appreciate a review for my first commit then

Apart from the commented part, your changes look good to me @juliushaertl

Could you review my changes another time, given that I implemented the logic to rename the directory and clean up old directories after your last review?

This is way more performant than iterating over all existing sessions.

Signed-off-by: Jonas <jonas@freesources.org>

public function clearAll(): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

truncate and delete are different things. Truncate might be faster than delete, but not all DB engines support it afaik. Not sure what is the current state in doctrine. OK for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with 120.000 entries and it was super fast. So I guess it's ok for now 😬

Copy link
Member

@blizzz blizzz Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -137,6 +148,12 @@ public function deleteByDocumentId(int $documentId): int {
return $qb->executeStatement();
}

public function clearAll(): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

@@ -62,6 +62,12 @@ public function deleteAll(int $documentId): void {
->executeStatement();
}

public function clearAll(): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

@blizzz
Copy link
Member

blizzz commented Jun 17, 2024

/backport to stable29

@blizzz
Copy link
Member

blizzz commented Jun 17, 2024

/backport to stable28

@blizzz
Copy link
Member

blizzz commented Jun 17, 2024

/backport to stable27

@blizzz
Copy link
Member

blizzz commented Jun 17, 2024

Runner 9 was green before, Runner 1 is a known Flaky test → Merging.

@blizzz blizzz merged commit 4e9ca5f into main Jun 17, 2024
60 of 63 checks passed
@blizzz blizzz deleted the fix/reset_sessions branch June 17, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Session cleanup
3 participants