Skip to content

Commit c3c84c6

Browse files
authored
Use thread local random for request id generation (#52344)
Currently we used the secure random number generate when generating http request ids in the security AuditUtil. We do not need to be using this level of randomness for this use case. Additionally, this random number generator involves locking that blocks the http worker threads at high concurrency loads. This commit modifies this randomness generator to use our reproducible randomness generator for Elasticsearch. This generator will fall back to thread local random when used in production.
1 parent ca29668 commit c3c84c6

File tree

1 file changed

+2
-1
lines changed
  • x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit

1 file changed

+2
-1
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package org.elasticsearch.xpack.security.audit;
77

88
import org.elasticsearch.action.IndicesRequest;
9+
import org.elasticsearch.common.Randomness;
910
import org.elasticsearch.common.Strings;
1011
import org.elasticsearch.common.UUIDs;
1112
import org.elasticsearch.common.util.concurrent.ThreadContext;
@@ -64,7 +65,7 @@ private static String generateRequestId(ThreadContext threadContext, boolean che
6465
+ existing + "] already registered");
6566
}
6667
}
67-
final String requestId = UUIDs.randomBase64UUID();
68+
final String requestId = UUIDs.randomBase64UUID(Randomness.get());
6869
// Store as a header (not transient) so that it is passed over the network if this request requires execution on other nodes
6970
threadContext.putHeader(AUDIT_REQUEST_ID, requestId);
7071
return requestId;

0 commit comments

Comments
 (0)