Skip to content

Commit 206cd67

Browse files
comment about race-condition
1 parent 734ce44 commit 206cd67

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/ecto/uuid.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ defmodule Ecto.UUID do
285285
defp next_ascending(time_unit) when time_unit in [:millisecond, :nanosecond] do
286286
timestamp_ref =
287287
with nil <- :persistent_term.get({__MODULE__, time_unit}, nil) do
288+
# There is a small chance of a race-condition with this
289+
# lazy-initialization of the persistent_term.
288290
timestamp_ref = :atomics.new(1, signed: false)
289291
:ok = :persistent_term.put({__MODULE__, time_unit}, timestamp_ref)
290292
timestamp_ref

0 commit comments

Comments
 (0)