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

Prune command fails to delete records then using with mysql on planetscale #1410

Closed
Arturas0 opened this issue Nov 18, 2023 · 7 comments
Closed

Comments

@Arturas0
Copy link

Telescope Version

4.17.2

Laravel Version

10.31.0

PHP Version

8.2

Database Driver & Version

MySQL on planet scale

Description

After changing db from MySQL to MySQL on planet scale command php artisan telescope:prune fails, then table telescope_entries has more than 100k records. Planet scale has limits (https://planetscale.com/docs/reference/planetscale-system-limits) and one of them is Per-query rows returned, updated, or deleted 100k.

Steps To Reproduce

  1. Use planet scale as DB;
  2. Insert 101k records to table telescope_entries;
  3. Run command php artisan telescope:prune
@driesvints
Copy link
Member

But deletes for prunes are already chunked by 1000 items each so we never delete 100K records at once? So I don't understand how this is possible?

https://github.com/laravel/telescope/blob/4.x/src/Storage/DatabaseEntriesRepository.php#L352

@Arturas0
Copy link
Author

Chuncks are used to delete records, but before deletion, data is selected.
If I am correct, than this query $query = $this->table('telescope_entries')->where('created_at', '<', $before) translates to SQL which tries to select data and causes an error.

Screenshot_1

@driesvints
Copy link
Member

No, that's just a query builder instance. ->take() is applied to it afterwards which limits the result to 1000.

@Arturas0
Copy link
Author

Thank you for clarification. I tried to recreate issue, I installed telescope for new project with db planet scale, after inserting more than 100k records into table telescope_entries command php artisan telescope:prune worked correctly, so it looks like I was incorrect prune command works as expected.

But I had problem with telescope button clear entries than table has more than 100k records.
Screenshot 2023-11-19 at 14 58 47

After clicking this button I can see query was executed:
Screenshot 2023-11-19 at 14 55 44

And then I saw error from planet scale, after manually deleting some records, to have less than 100k query was executed successfully:
Screenshot 2023-11-19 at 14 57 18

@driesvints
Copy link
Member

Okay I've found now where this is:

$this->table('telescope_entries')->delete();
$this->table('telescope_monitoring')->delete();

We'd probably need to do a chunk to clear entries here. Would love a PR for this.

Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

@driesvints
Copy link
Member

A PR was merged for this, thanks

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