Skip to content

Use v4 instead of v1 uuids#5235

Merged
chnn merged 2 commits intoinfluxdata:masterfrom
ctavan:use-v4-instead-of-v1-uuids
Jul 28, 2019
Merged

Use v4 instead of v1 uuids#5235
chnn merged 2 commits intoinfluxdata:masterfrom
ctavan:use-v4-instead-of-v1-uuids

Conversation

@ctavan
Copy link
Copy Markdown
Contributor

@ctavan ctavan commented Jul 21, 2019

Mostly copied over from influxdata/influxdb#14374

I'm a co-author of the uuid npm module which is being used in some places within the code base of influxdb.

I'm currently trying to understand real-world use cases of time-based UUIDs ("v1 UUIDs").

I found two occurrence where v1 UUIDs were being used instead of v4 UUIDs and I was wondering if this case really requires the semantically much more complex v1 UUIDs or whether we could live equally well with purely random v4 UUIDs? Please see my commit messages for more details.

At least the test suite still passes after my changes, so apparently this doesn't seem to introduce any known regressions.

I'd be really curious to understand the motivation for choosing v1 over v4 UUIDs in the first place, so any feedback on this would be highly appreciated!

@bthesorceror as far as I can tell from the git history it seems like you have introduced both usages of v1 UUIDs so I'd be particularly interested in your feedback.

  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Rebased/mergeable
  • Tests pass
  • swagger.json updated (if modified Go structs or API)
  • Sign CLA (if not already signed)

ctavan added 2 commits July 21, 2019 14:35
This uses a purely random v4 UUID instead of a time-based v1 UUID for
the worker message IDs (which were introduced in
1a76a29).

v1 UUID are based on current time and the hardware MAC address of the
machine where they are being generated (although the implementation in
the npm uuid module uses generates a random fake MAC address). As such
they have much more complex semantics than v4 UUIDs which are simply
randomly generated.

Unless there's a specific requirement for the special semantics of v1
UUIDs it is simpler and less error prone to simply go for v4 UUIDs
whenever just a unique identifier is needed.
This uses a purely random v4 UUID instead of a time-based v1 UUID for
the time series UUIDs (which were introduced in
dba9e28 and
2fba2b9).

As far as I can tell from
https://github.com/influxdata/chronograf/blob/b6f6118b65b9a6ba5877e00dc98bab19f80a224f/server/influx.go#L91-L94
the server uses
https://github.com/influxdata/chronograf/blob/b6f6118b65b9a6ba5877e00dc98bab19f80a224f/id/uuid.go#L15
to generate the `response.uuid` field where clearly a v4 UUID is being
generated. Mixing this with v1 UUIDs in the client code seems odd.

v1 UUID are based on current time and the hardware MAC address of the
machine where they are being generated (although the implementation in
the npm uuid module uses generates a random fake MAC address). As such
they have much more complex semantics than v4 UUIDs which are simply
randomly generated.

Unless there's a specific requirement for the special semantics of v1
UUIDs it is simpler and less error prone to simply go for v4 UUIDs
whenever just a unique identifier is needed.
Copy link
Copy Markdown
Contributor

@chnn chnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the motivation here is the same as we discussed on the influxdb repo. That is, v4 uuids will do just fine for us. Thanks @ctavan!

@chnn chnn merged commit 115d3b8 into influxdata:master Jul 28, 2019
@russorat russorat added this to the 1.7.13 milestone Aug 1, 2019
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.

3 participants