Skip to content

workload/tpcc: use explicit primary key in tpcc.history#23827

Merged
petermattis merged 1 commit intocockroachdb:masterfrom
petermattis:pmattis/workload-tpcc-history
Mar 15, 2018
Merged

workload/tpcc: use explicit primary key in tpcc.history#23827
petermattis merged 1 commit intocockroachdb:masterfrom
petermattis:pmattis/workload-tpcc-history

Conversation

@petermattis
Copy link
Copy Markdown
Collaborator

Use an explicit primary key in tpcc.history which is identical to the
implicit one. When generating fixture data, fill in the rowid using a
random 63-bit integer rather than relying on sequential values generated
during import. This matches the rowid generation used by the tpcc load
generator.

Fixes #23544

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@petermattis
Copy link
Copy Markdown
Collaborator Author

Heh, I hit a duplicate key violation when generating a tpcc-10k dataset: Error: creating backup for table history: pq: SST creation error at /Table/51/1/724811875183904935/0; this can happen when a primary or unique index has duplicate keys: Invalid argument: Keys must be added in order.

I see two options here: I can tweak the generation of these random rowids, or I can switch to using a UUID. The latter is what we'd recommend for production use. Let me see how bad it is.

@petermattis petermattis force-pushed the pmattis/workload-tpcc-history branch from d814c08 to 111dba2 Compare March 15, 2018 12:44
@petermattis
Copy link
Copy Markdown
Collaborator Author

Ok, this is ready for another look.


Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion.


pkg/workload/tpcc/ddls.go, line 72 at r1 (raw file):

	// No PK necessary for this table.
	tpccHistorySchema = `(
		rowid    uuid PRIMARY KEY DEFAULT uuid_v4()::uuid,

@jordanlewis uuid_v4() returns BYTES. I can't recall whether it is feasible to have a specialization that also returns UUID. Do you know?


Comments from Reviewable

@jordanlewis
Copy link
Copy Markdown
Member

:lgtm:


Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion.


pkg/workload/tpcc/ddls.go, line 72 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

@jordanlewis uuid_v4() returns BYTES. I can't recall whether it is feasible to have a specialization that also returns UUID. Do you know?

Use gen_random_uuid(), which produces a uuid type.


Comments from Reviewable

@petermattis petermattis force-pushed the pmattis/workload-tpcc-history branch from 111dba2 to d98cd6d Compare March 15, 2018 12:54
@petermattis
Copy link
Copy Markdown
Collaborator Author

Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion.


pkg/workload/tpcc/ddls.go, line 72 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

Use gen_random_uuid(), which produces a uuid type.

Done. Unfortunate that we have 2 functions that or so similar except in their return type (and names).


Comments from Reviewable

@jordanlewis
Copy link
Copy Markdown
Member

Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


pkg/workload/tpcc/ddls.go, line 72 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Done. Unfortunate that we have 2 functions that or so similar except in their return type (and names).

Yeah - gen_random_uuid is what pg calls it.


Comments from Reviewable

Use an explicit UUID primary key in tpcc.history.

Fixes cockroachdb#23544

Release note: None
@petermattis petermattis force-pushed the pmattis/workload-tpcc-history branch from d98cd6d to 904aff7 Compare March 15, 2018 13:30
@petermattis petermattis merged commit e70eb93 into cockroachdb:master Mar 15, 2018
@petermattis petermattis deleted the pmattis/workload-tpcc-history branch March 15, 2018 17:20
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

Successfully merging this pull request may close these issues.

cmd/workload: adjust tpcc.history.rowid generation

3 participants