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

TiDB kine table data only increase not decrease fast #3360

Closed
zzps opened this issue May 21, 2021 · 16 comments
Closed

TiDB kine table data only increase not decrease fast #3360

zzps opened this issue May 21, 2021 · 16 comments

Comments

@zzps
Copy link

zzps commented May 21, 2021

K3s Version: v1.20.4+k3s1

Node(s) CPU architecture, OS, and Version: amd64+centos7.8

Cluster Configuration:2servers+2agent

Describe the bug:
deploy k3s about one month with external database TIDB,and I found 13,483,866 rows data,hold 16GB disk space.
check the sql just include select insert without any delete
Steps To Reproduce:

  • Installed K3s: install k3s offline yestoday night,and the morning today I found there are 156,614 rows

Expected behavior:
small data,not increase
Actual behavior:

Additional context / logs:

@brandond
Copy link
Member

external database TIDB
Can you share more information on what database engine you're using?

check the sql just include select insert without any delete
Kine uses the SQL database as a time series database. Writes to the datastore insert new rows to store resource revisions, and old revisions are pruned in batches every 5 minutes or so. You won't see deletes very frequently.

install k3s offline yestoday night,and the morning today I found there are 156,614 rows

What do you have running on this cluster? What database engine and version? What sort of storage is hosting the database?

@zzps
Copy link
Author

zzps commented May 21, 2021

E4V%@)D QK28ZZEBB@)P213
O$9 4M0QXEIL6(C}FN1OY}L
BZFTRPFHUJA798ASV6GXLT](https://user-images.githubusercontent.com/33255974/119093241-0a660c80-ba42-11eb-9b76-9a1620777ce8.png) ![%YAEJ0MB08_ 9GS{K%%@J5X](https://user-images.githubusercontent.com/33255974/119093401-400af580-ba42-11eb-8934-160561bebe8e.png) ![A 8S`%@HXL3FERUJUZ{ {L

above are the image about database infomation and the application running on k3s. and I am absolutely sure it never run delete sql to decrease rows. it is terrible. I must consider to fix it before it become disaster

@zzps
Copy link
Author

zzps commented May 21, 2021

C8979NDOAOZLL7`QG_TX%)X

@zzps
Copy link
Author

zzps commented May 21, 2021

to verify and find problem I yestoday night deploy a new k3s cluster with two server without agent ,external storage TIDB 5.0.1,and no any application running on the new k3s cluster, and today morning there are 156,614 rows data in the kine table. and now the afternoon there are 207,273 rows data !!!!! oh my god!!!

@brandond
Copy link
Member

brandond commented May 21, 2021

What exactly is TIDB? It appears to be something that emulates the MySQL database protocol using a different engine? This is definitely not something we've tested and is not supported. Can you reproduce this same behavior with a true MySQL database?

@brandond brandond changed the title mysql kine table data only increase not decrease fast TiDB kine table data only increase not decrease fast May 21, 2021
@zzps
Copy link
Author

zzps commented May 21, 2021

What exactly is TIDB? It appears to be something that emulates the MySQL database protocol using a different engine? This is definitely not something we've tested and is not supported. Can you reproduce this same behavior with a true MySQL database?

Ok , I change it to real mysql now. by the TIDB is 100% compatible with mysql

@brandond
Copy link
Member

brandond commented May 21, 2021

Compatible doesn't mean identical. We've seen other users run into issues when attempting to use CockroachDB without proper serialization constraints enabled. Kine has strict requirements around the sequential ordering of the auto-increment primary key that many distributed database engines don't implement, or don't enable by default, in the interest of scalability.

And, as I said earlier, deletes happen in batches once every 5 minutes so you are unlikely to see them in a random sampling of the transaction log.

@zzps
Copy link
Author

zzps commented May 21, 2021

Compatible doesn't mean identical. We've seen other users run into issues when attempting to use CockroachDB without proper serialization constraints enabled. Kine has strict requirements around the sequential ordering of the auto-increment primary key that many distributed database engines don't implement, or don't enable by default, in the interest of scalability.

OK . for preciseness. I test it on real mysql right now!!! and will tell you the result

@brandond
Copy link
Member

brandond commented May 21, 2021

From the TiDB docs:

Auto-increment ID
In TiDB, auto-increment columns are only guaranteed to be unique and incremental on a single TiDB server, but they are not guaranteed to be incremental among multiple TiDB servers or allocated sequentially.

This specifically will not work for Kine.

There are many other differences from standard MySQL, I would definitely not say that it is 100% compatible with applications that expect MySQL behavior.
https://docs.pingcap.com/tidb/dev/mysql-compatibility

@zzps
Copy link
Author

zzps commented May 21, 2021

hi big brother! I have change to mysql8.0.25, and redeploy k3s cluster again. and put my eye on the kine data increase, finally I surpriselly found the rows count increase to 2356 ,and next second I refresh it change to 1467. it works!

@zzps zzps closed this as completed May 21, 2021
@afritzler
Copy link

I have seen the same issue happening on CockroachDB k3s-io/kine#87 Was anybody out here able to fix the compaction query for mysql/posgres-ish DB derivates?

@zzps
Copy link
Author

zzps commented May 28, 2021

I have seen the same issue happening on CockroachDB k3s-io/kine#87 Was anybody out here able to fix the compaction query for mysql/posgres-ish DB derivates?

for now,you must use the standard MySQL ,without any compatible mysql product. by the way I really recommend you to change the kine autoincreament id type from int to bigint for 5-10 insert per sencond!

@afritzler
Copy link

afritzler commented May 28, 2021

Any hints on how to do that? :). Do I need to change the schema in the kine source?

@zzps
Copy link
Author

zzps commented May 28, 2021

the feild ' id 'of kine table created by k3s is 'int' type, and the insert action is quickly. so it is not longer for 'int'. change to 'bigint'
type for improve

@afritzler
Copy link

afritzler commented May 28, 2021

I was wondering if somebody managed to get cockroachDB/TiDB running via kine stable for while. Apart from the compaction issue I also see a problem with list queries when the API server builds up it's watch cache upon start up.

@zzps
Copy link
Author

zzps commented May 28, 2021

for personal opinion,I don't think the work of k3s external storage is satisfactory! but it is the fact. I faild it on TIDB, and the data size increase to 10,000,000 for only one month !

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

3 participants