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

Archive tables never purged #4

Open
mansj opened this issue Mar 20, 2019 · 5 comments
Open

Archive tables never purged #4

mansj opened this issue Mar 20, 2019 · 5 comments

Comments

@mansj
Copy link

mansj commented Mar 20, 2019

Hi there, first of all - thank you so much for developing this software, it was exactly what I was looking for, and works like a charm.

I can't seem to get the archived tables to be deleted. I've experimented with different settings for -k (--keep) but none are deleted, even though command-line output seems to claim it is doing so:

2019/03/20 16:06:05 Connecting to MySQL... 2019/03/20 16:06:05 Clearing old tables... 2019/03/20 16:06:05 All done

The user has DROP privileges.

@odino
Copy link
Owner

odino commented Mar 24, 2019

Hey @mansj happy to hear you're finding this useful!

The problem seems very weird! Can you try running the following query with the parameters you pass to docsql:

SELECT table_name FROM information_schema.tables where table_schema='%s' AND table_name LIKE \"%s_%%_archive\" ORDER BY table_name DESC LIMIT 10000 OFFSET %d"

(you'll need db, table, keep)

I suspect no tables are found here, thus they don't get deleted.

@mansj
Copy link
Author

mansj commented Mar 25, 2019

Thank you. I see a problem with the SQL you sent. There's a double '%' in the middle, right?

table_name LIKE \"%s_%%_archive\" should probably be table_name LIKE \"%s_%_archive\"

If I change that on my end when running the query manually (also omitting the OFFSET and the table_schema, which I don't know what needs to be filled in) the result works.

@odino
Copy link
Owner

odino commented Mar 25, 2019

The double % will be converted to a single % when Go formats our query, so that shouldn't be a problem (playground).

Schema is the name of your database, offset is the number of tables you want to preserve.

@mansj
Copy link
Author

mansj commented Mar 25, 2019

I see. In that case, the line seems to work as it is, because it returns all the archive tables, at the moment 117 of them in my database.

Here's the full line I'm running now:

SELECT table_name FROM information_schema.tables where table_schema='dm_stripped' AND table_name LIKE "dm_songs_%_archive" ORDER BY table_name DESC LIMIT 10000 OFFSET 10;

@mansj
Copy link
Author

mansj commented Mar 25, 2019

I also attempted to manually issue a "DROP TABLE" command as the user in question, and managed to drop an archive table no problem.

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