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

Deletion strategy not clearing indices for some mysql clients #21

Open
Fryie opened this issue May 21, 2015 · 1 comment
Open

Deletion strategy not clearing indices for some mysql clients #21

Fryie opened this issue May 21, 2015 · 1 comment

Comments

@Fryie
Copy link

Fryie commented May 21, 2015

We switched from truncation to deletion for a project of ours because for some reason truncation was incredibly slow on some clients (apparently this has been observed before).

Unfortunately, on some machines this breaks the tests because mysql is complaining about a duplicate index. So to me this suggests that the indices are not reliably reset on all clients.
The behaviour seems particularly erratic:

  • It works on my machine (Mac OS X Yosemite), on our CI server (I believe Debian or Ubuntu, although I'd have to check) and on a freshly set up Ubuntu VM
  • But it doesn't work on a freshly set up Arch Linux VM (regardless of whether I use mariadb or the official Oracle mysql), nor on my coworker's Ubuntu machine.

However, the behaviour differs only across machines, it's consistent on one specific machine.

I suppose it must have something to do with specific mysql configuration options, but I'm at a loss as to what it could be in particular.
I realise this is not a precise problem description but maybe somebody around here has a clue?

Edit:
On a second look, it doesn't even appear to be consistent on a single machine. At least it works perfectly fine in the Arch Linux VM today. That's even weirder.

Edit2:
Works on Arch Linux with MySQL, but not mariadb, it seems.

@redross
Copy link

redross commented May 22, 2015

Have something similar.
When using DatabaseCleaner.clean_with(:deletion), some records are not deleted. Looking at why this happens I see that:
DatabaseCleaner::ActiveRecord::SelectiveTruncation#tables_with_new_rows tries to select which tables should be deleted. But since information_schema.tables table only has "estimates of row sizes" the query:

SELECT table_name
FROM information_schema.tables
WHERE table_schema = '#{@db_name}' AND table_rows > 0

doesn't return some tables that do have records (but their description in information_schema says they don't).

Not sure what can be done here. Explicit count strategy would probably be too slow?

@botandrose botandrose transferred this issue from DatabaseCleaner/database_cleaner Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants