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

Fix erlang time module compatibility #883

Merged
merged 1 commit into from Oct 11, 2017

Conversation

Projects
None yet
2 participants
@nickva
Contributor

nickva commented Oct 9, 2017

Fix erlang time module compatibility

`now/0` is deprecated since Erlang 18.0, and a set of new time related
functions are available.

Usually `now/0` can be replaced with `os:timestamp/0`, however in some
instances it was used effectively to produce monotonically incrementing values
rather than timestamps. So added a new `couch_util:unique_monotonic_integer/0`.

Most functional changes are in couch_uuid module. There `now/0` was used both
as a timestamp and for uniqueness. To emulate previous behavior, a local
incrementing clock sequence is used. If `os:timestamp/0` does not advance since
last call then the local clock is advanced by 1 microsecond and that's used to
generate the next V1 UUIDs. As soon as os:timestamp/0` catches up, the local
sequence reset to that latest value.

Also exported function `utc_random/0` was not used, after updating the function
it wasn't exported anymore.
@davisp

davisp requested changes Oct 10, 2017 edited

Whoops, looks like I never submitted this PR review. So here it is.

Show outdated Hide outdated src/couch/src/couch_auth_cache.erl
Show outdated Hide outdated src/couch/src/couch_uuids.erl
@davisp

+1

after my super minor nit.

Show outdated Hide outdated src/couch/src/couch_uuids.erl
Fix erlang time module compatibility
`now/0` is deprecated since Erlang 18.0, and a set of new time related
functions are available.

Usually `now/0` can be replaced with `os:timestamp/0`, however in some
instances it was used effectively to produce monotonically incrementing values
rather than timestamps. So added a new `couch_util:unique_monotonic_integer/0`.

Most functional changes are in couch_uuid module. There `now/0` was used both
as a timestamp and for uniqueness. To emulate previous behavior, a local
incrementing clock sequence is used. If `os:timestamp/0` does not advance since
last call then the local clock is advanced by 1 microsecond and that's used to
generate the next V1 UUIDs. As soon as os:timestamp/0` catches up, the local
sequence reset to that latest value.

Also exported function `utc_random/0` was not used, after updating the function
it wasn't exported anymore.

@nickva nickva merged commit a99cc6f into apache:master Oct 11, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@nickva nickva deleted the cloudant:time-compatibility-module branch Oct 11, 2017

janl added a commit to janl/couchdb that referenced this pull request Oct 28, 2017

janl added a commit that referenced this pull request Oct 29, 2017

wohali added a commit that referenced this pull request Oct 31, 2017

wohali added a commit that referenced this pull request Nov 1, 2017

wohali added a commit that referenced this pull request Nov 1, 2017

lucidNTR added a commit to cloudless-hq/couchdb that referenced this pull request Jan 2, 2018

Merge commit 'f84faa532ee7341d76f7cecdd416f8728d72ecc1' into cloudant…
…-search

* commit 'f84faa532ee7341d76f7cecdd416f8728d72ecc1': (4288 commits)
  re-add query
  Update NOTICE: remove autoconf/m4 references and revert react patents note
  Configurable delay before retrying on missing_doc error
  Update jiffy to use dedupe_keys
  Return error 410 on temporary view request
  fix(peruser_test): on slow CI vms, we can get Cluster timeouts
  Updating verifyinstall URL
  whitespace
  add delay for bulk_delete and create
  up delay
  use delay instead
  use string for w value
  Update w value for deletion since n=1
  feat: port time funs, as per #883
  fix: peruser tests: use spinlocks instead of timer:sleep()
  Alias /_node/_local/... to /_node/<nodename>@<hostname>/...
  Travis: s/20.0/20.1 for build
  Disable eval() and Function() constructor in JS by default
  Blacklist some config sections from HTTP PUT/DELETE operations
  Cleanups for 2.1.1 proper version tagging
  ...

# Conflicts:
#	Makefile
#	Makefile.win
#	dev/run
#	rebar.config.script
#	rel/reltool.config

willholley added a commit to willholley/couchdb that referenced this pull request May 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment