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

after print "rollback checkpoint" in log, unistore folder size grows #5344

Closed
lance6716 opened this issue May 6, 2022 · 6 comments · Fixed by #5350
Closed

after print "rollback checkpoint" in log, unistore folder size grows #5344

lance6716 opened this issue May 6, 2022 · 6 comments · Fixed by #5350
Assignees
Labels
affects-5.3 affects-5.4 affects-6.0 area/dm Issues or PRs related to DM. severity/major type/bug The issue is confirmed as a bug.

Comments

@lance6716
Copy link
Contributor

lance6716 commented May 6, 2022

What did you do?

logger.Info("rollback checkpoint", zap.Stringer("from", from), zap.Stringer("to", point.FlushedMySQLLocation()))
// schema changed
if err := schemaTracker.DropTable(table); err != nil {
logger.Warn("failed to drop table from schema tracker", log.ShortError(err))
}
if point.ti != nil {
// TODO: Figure out how to recover from errors.
if err := schemaTracker.CreateSchemaIfNotExists(schemaName); err != nil {
logger.Error("failed to rollback schema on schema tracker: cannot create schema", log.ShortError(err))
}
if err := schemaTracker.CreateTableIfNotExists(table, point.ti); err != nil {
logger.Error("failed to rollback schema on schema tracker: cannot create table", log.ShortError(err))
}

mock the logic of rollback checkpoint

	for i := 0; i < 10000; i++ {
		err = tracker.DropTable(tbl)
		c.Assert(err, IsNil)

		err = tracker.CreateSchemaIfNotExists("test")
		c.Assert(err, IsNil)
		err = tracker.CreateTableIfNotExists(tbl, oriTi)
		c.Assert(err, IsNil)
	}

during the test

# lance @ LAPTOP-AK9BOS6J in ~/go/src/github.com/pingcap/tiflow on git:630896740
 x [19:38:27]
$ du -h /tmp/tidb-unistore-temp944770732
16M     /tmp/tidb-unistore-temp944770732/kv
16M     /tmp/tidb-unistore-temp944770732

# lance @ LAPTOP-AK9BOS6J in ~/go/src/github.com/pingcap/tiflow on git:630896740
 x [19:38:42]
$ du -h /tmp/tidb-unistore-temp944770732
104M    /tmp/tidb-unistore-temp944770732/kv
104M    /tmp/tidb-unistore-temp944770732

# lance @ LAPTOP-AK9BOS6J in ~/go/src/github.com/pingcap/tiflow on git:630896740
 x [19:40:22]
$ du -h /tmp/tidb-unistore-temp944770732
195M    /tmp/tidb-unistore-temp944770732/kv
195M    /tmp/tidb-unistore-temp944770732

So if the task is resumed for many times (which means the task has a resumable error), the size of unistore folder will grow.

What did you expect to see?

the size of /tmp/tidb-unistore-temp944770732 has an upper-bound

What did you see instead?

No response

Versions of the cluster

v5.3.1

current status of DM cluster (execute query-status <task-name> in dmctl)

(paste current status of DM cluster here)
@lance6716
Copy link
Contributor Author

lance6716 commented May 6, 2022

since we found the first and most severe problem in #5334 , I think changing implementation of schema tracker is less urgent.

@lance6716
Copy link
Contributor Author

	for i := 0; i < 10000; i++ {
		err = tracker.Exec(ctx, "test", "DROP TABLE t")
		c.Assert(err, IsNil)

		err = tracker.Exec(ctx, "", "CREATE DATABASE IF NOT EXISTS test")
		c.Assert(err, IsNil)
		err = tracker.Exec(ctx, "test", "CREATE TABLE t (c varchar(20000)) charset=utf8")
		c.Assert(err, IsNil)
	}

same effects

@lance6716
Copy link
Contributor Author

lance6716 commented May 6, 2022

after some discussion, this space may be occupied by DDL history job and we have no way to clean it. Maybe the fix is that we close schema tracker and remove the unistore folder after the task is paused.

Or we think about #5334

@GMHDBJD
Copy link
Contributor

GMHDBJD commented May 6, 2022

Maybe the fix is that we close schema tracker

looks good to me

@lance6716 lance6716 self-assigned this May 7, 2022
@lance6716
Copy link
Contributor Author

lance6716 commented May 7, 2022

after some discussion, this space may be occupied by DDL history job and we have no way to clean it. Maybe the fix is that we close schema tracker and remove the unistore folder after the task is paused.

Or we think about #5334

just created 500 tables in a task (ADMIN SHOW DDL JOBS has 535 rows), the disk usage is 257M...

we should adjust some default options

https://github.com/pingcap/tidb/blob/f6ce33761b7c4672c98199cdd194029dc5ef546a/store/mockstore/unistore/config/config.go#L141

@lance6716
Copy link
Contributor Author

lance6716 commented May 8, 2022

Maybe the fix is that we close schema tracker

looks good to me

Just found that operate-schema should let DM-master directly modify the table checkpoint after this 😂

plan to forward to DM-worker to reuse router and parser

lance6716 added a commit that referenced this issue May 13, 2022
…#5419)

* tracker(dm): close and recreate tracker when pause and resume (#5350)

close #5344

* fix cherry-pick

Signed-off-by: lance6716 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.3 affects-5.4 affects-6.0 area/dm Issues or PRs related to DM. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants