From 7a892558aee46bb2462f02e65375d4658a24b66f Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Sun, 8 Feb 2026 20:41:16 +0100 Subject: [PATCH 1/2] fix(uuid): better handle too many generation --- src/geode/basic/uuid.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/geode/basic/uuid.cpp b/src/geode/basic/uuid.cpp index 69a04fed2..ce386860e 100644 --- a/src/geode/basic/uuid.cpp +++ b/src/geode/basic/uuid.cpp @@ -72,7 +72,7 @@ namespace private: // Tuning parameters static constexpr std::uint64_t kMaxDriftMs = - 1000; // Max drift ahead of real time + 2000; // Max drift ahead of real time static constexpr unsigned kBackoffThreshold = 8; // CAS failures before sleep static constexpr unsigned kBackoffSleepUs = 1; // Initial sleep duration @@ -239,9 +239,14 @@ namespace geode { uuid::uuid() { + static constexpr index_t MAX_SAFETY_COUNT = 1000; + static constexpr absl::Duration INITIAL_SLEEP = + absl::Microseconds( 100 ); + static constexpr absl::Duration MAX_SLEEP = absl::Milliseconds( 50 ); UUIDv7Generator gen; bool generated{ false }; - for( const auto i : Range{ 10 } ) + auto sleep = INITIAL_SLEEP; + for( const auto i : Range{ MAX_SAFETY_COUNT } ) { geode_unused( i ); if( auto bytes = gen.generate() ) @@ -250,6 +255,8 @@ namespace geode generated = true; break; } + absl::SleepFor( sleep ); + sleep = std::min( sleep * 2., MAX_SLEEP ); } OPENGEODE_EXCEPTION( generated, "[uuid] could not generate uuid" ); } From 2daface332eecd9308005730be244f7409748dca Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Sun, 8 Feb 2026 20:42:51 +0100 Subject: [PATCH 2/2] revert --- src/geode/basic/uuid.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/geode/basic/uuid.cpp b/src/geode/basic/uuid.cpp index ce386860e..d572e20f7 100644 --- a/src/geode/basic/uuid.cpp +++ b/src/geode/basic/uuid.cpp @@ -72,7 +72,7 @@ namespace private: // Tuning parameters static constexpr std::uint64_t kMaxDriftMs = - 2000; // Max drift ahead of real time + 1000; // Max drift ahead of real time static constexpr unsigned kBackoffThreshold = 8; // CAS failures before sleep static constexpr unsigned kBackoffSleepUs = 1; // Initial sleep duration @@ -323,4 +323,4 @@ namespace std { return absl::HashOf( uuid.bytes_ ); } -} // namespace std \ No newline at end of file +} // namespace std