SQL Database growing over the size of 10Gb
Answered
Hi All,
We have a TeamCity server with a SQL Server Express database (limited to ~10Gb. It was installed and configured in 2017. The database was initially created with an initial size of 10Gb. We configured cleanup rules to avoid to keep useless history files and useless information.
But recently we faced the problem that the database could not automatically growth due the limit of the SQL Server Express database. To solve the problem we moved to a real SQL Server but we would like to know why the database grow indefinitely? We thought that having some cleanup policies would have prevented such a problem.
All your advises are welcome.
Thanks in advance,
Stephane Rancurel
Please sign in to leave a comment.
Hi!
It would be useful to know what tables are the top disk consumers. Perhaps, you could configure stricter clean-up policies to clean the builds more aggressively. But please note that currently some tables are not cleaned up, e.g., the
vcs_change
table. There's a related task in our tracker: TW-25099.Cheers,
-Anatoly
Hi Anatoly,
Thanks for your reply. I launched a request in the database to get the size used by each tables of the Database. The table test_names consume 10Gb of the space. Please have a look to the screenshot below.
Thanks in advance for your help
Stephane
Stephane,
The
test_names
table contains all test names seen by TeamCity server in your builds. TeamCity should clean it up according to the Clean-up Rules in the project settings. 6.8 million rows are quite a lot, meaning most likely, the builds running the tests are not cleaned up.The SQL query below should shown you which build configurations have the most test names associated with them. It would make sense to look at the clean-up rules applied to those configurations. Please, ensure they are strict enough and work as expected.
-Anatoly
Hi Anatoly,
I ran the SQL request and got the id of the build configuration that contains most of the test_names.
Then I had a look to the clean-up rules of the project and it is set as the other projects.
Any advise on this will appreciated.
Stephane
Stephane,
Apparently, clean-up isn't removing the build history for some reason. Besides not having enough successful builds in a branch to satisfy the criteria specified in your clean-up rule, the builds won't be cleaned up if:
-Anatoly
Anatoly,
I ran your two last queries, and there are no depency chain for the project, and no builds are pinned.
It seems that the Clean-up do some work. It ran this morning and I re-ran your SQL request and here is the result:
So it seems that records are being removed but the size of database is still growing. Please have a look to the size used by the table compared to my first message.
Thanks for your help
Stephane
Stephane,
I'd recommend taking a look at the build history and making sure your clean-up policies work as expected, i.e. there aren't any unexpectedly old builds in the build configuration history. If the policies do in fact work as expected, you might need to make them stricter to keep even fewer builds in history.
-Anatoly
Hello,
Maybe someone will have similar problem, so i will leave my findings here.
I had the same problem and after some investigation, i found out that many of rows in dbo.test_names table were “ghost” rows (table dbo.test_info was missing info for rows). Because of it, i think clean-up policies weren't able to clean up all data from database.
Running following query:
SELECT
CASE
WHEN ti.test_name_id IS NULL THEN NULL
ELSE 'NOT NULL'
END as chck
,COUNT(*) cnt
FROM dbo.test_names as tn
LEFT JOIN dbo.test_info as ti
ON ti.test_name_id = tn.id
GROUP BY
CASE
WHEN ti.test_name_id IS NULL THEN NULL
ELSE 'NOT NULL'
END
returned 4 509 562 rows:
in my opinion all 4509562 rows can be deleted safely. If you want to delete the data, do a backup first!
If anyone has problem with TeamCity database size, please check above SQL if you have similar issue.