Skip to content

Commit 6eea8c6

Browse files
authored
Merge branch 'trunk' into renovate/org.redisson-redisson-3.x
2 parents f8353a0 + 1884d3f commit 6eea8c6

File tree

6 files changed

+122
-36
lines changed

6 files changed

+122
-36
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.3.1
1+
7.4.1

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bazel_dep(name = "contrib_rules_jvm", version = "0.27.0")
1212
bazel_dep(name = "platforms", version = "0.0.10")
1313

1414
# Required for the closure rules
15-
bazel_dep(name = "protobuf", version = "29.1", dev_dependency = True, repo_name = "com_google_protobuf")
15+
bazel_dep(name = "protobuf", version = "29.2", dev_dependency = True, repo_name = "com_google_protobuf")
1616

1717
# Required for rules_rust to import the crates properly
1818
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
@@ -177,7 +177,7 @@ maven.install(
177177
"com.google.auto:auto-common:1.2.2",
178178
"com.google.auto.service:auto-service:1.1.1",
179179
"com.google.auto.service:auto-service-annotations:1.1.1",
180-
"com.google.googlejavaformat:google-java-format:jar:1.25.0",
180+
"com.google.googlejavaformat:google-java-format:1.25.2:1.25.0",
181181
"com.graphql-java:graphql-java:22.3",
182182
"dev.failsafe:failsafe:3.3.2",
183183
"io.grpc:grpc-context:1.68.1",

java/src/org/openqa/selenium/grid/distributor/GridModel.java

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,12 @@ public void release(SessionId id) {
400400
}
401401
}
402402

403-
public void reserve(NodeStatus status, Slot slot) {
403+
/**
404+
* A helper to reserve a slot of a node. The writeLock must be acquired outside to ensure the view
405+
* of the NodeStatus is the current state, otherwise concurrent calls to amend will work with an
406+
* outdated view of slots.
407+
*/
408+
private void reserve(NodeStatus status, Slot slot) {
404409
Instant now = Instant.now();
405410

406411
Slot reserved =
@@ -490,30 +495,29 @@ public void updateHealthCheckCount(NodeId id, Availability availability) {
490495
}
491496
}
492497

498+
/**
499+
* A helper to replace the availability and a slot of a node. The writeLock must be acquired
500+
* outside to ensure the view of the NodeStatus is the current state, otherwise concurrent calls
501+
* to amend will work with an outdated view of slots.
502+
*/
493503
private void amend(Availability availability, NodeStatus status, Slot slot) {
494504
Set<Slot> newSlots = new HashSet<>(status.getSlots());
495505
newSlots.removeIf(s -> s.getId().equals(slot.getId()));
496506
newSlots.add(slot);
497507

498508
NodeStatus node = getNode(status.getNodeId());
499509

500-
Lock writeLock = lock.writeLock();
501-
writeLock.lock();
502-
try {
503-
nodes.remove(node);
504-
nodes.add(
505-
new NodeStatus(
506-
status.getNodeId(),
507-
status.getExternalUri(),
508-
status.getMaxSessionCount(),
509-
newSlots,
510-
availability,
511-
status.getHeartbeatPeriod(),
512-
status.getSessionTimeout(),
513-
status.getVersion(),
514-
status.getOsInfo()));
515-
} finally {
516-
writeLock.unlock();
517-
}
510+
nodes.remove(node);
511+
nodes.add(
512+
new NodeStatus(
513+
status.getNodeId(),
514+
status.getExternalUri(),
515+
status.getMaxSessionCount(),
516+
newSlots,
517+
availability,
518+
status.getHeartbeatPeriod(),
519+
status.getSessionTimeout(),
520+
status.getVersion(),
521+
status.getOsInfo()));
518522
}
519523
}

java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ public LocalDistributor add(Node node) {
355355
// An exception occurs if Node heartbeat has started but the server is not ready.
356356
// Unhandled exception blocks the event-bus thread from processing any event henceforth.
357357
NodeStatus initialNodeStatus;
358+
Runnable healthCheck;
358359
try {
359360
initialNodeStatus = node.getStatus();
360361
if (initialNodeStatus.getAvailability() != UP) {
@@ -363,8 +364,17 @@ public LocalDistributor add(Node node) {
363364
// We do not need to add this Node for now.
364365
return this;
365366
}
366-
model.add(initialNodeStatus);
367-
nodes.put(node.getId(), node);
367+
// Extract the health check
368+
healthCheck = asRunnableHealthCheck(node);
369+
Lock writeLock = lock.writeLock();
370+
writeLock.lock();
371+
try {
372+
nodes.put(node.getId(), node);
373+
model.add(initialNodeStatus);
374+
allChecks.put(node.getId(), healthCheck);
375+
} finally {
376+
writeLock.unlock();
377+
}
368378
} catch (Exception e) {
369379
LOG.log(
370380
Debug.getDebugLogLevel(),
@@ -373,10 +383,6 @@ public LocalDistributor add(Node node) {
373383
return this;
374384
}
375385

376-
// Extract the health check
377-
Runnable healthCheck = asRunnableHealthCheck(node);
378-
allChecks.put(node.getId(), healthCheck);
379-
380386
updateNodeStatus(initialNodeStatus, healthCheck);
381387

382388
LOG.info(
@@ -415,7 +421,15 @@ private void updateNodeStatus(NodeStatus status, Runnable healthCheck) {
415421

416422
private Runnable runNodeHealthChecks() {
417423
return () -> {
418-
ImmutableMap<NodeId, Runnable> nodeHealthChecks = ImmutableMap.copyOf(allChecks);
424+
ImmutableMap<NodeId, Runnable> nodeHealthChecks;
425+
Lock readLock = this.lock.readLock();
426+
readLock.lock();
427+
try {
428+
nodeHealthChecks = ImmutableMap.copyOf(allChecks);
429+
} finally {
430+
readLock.unlock();
431+
}
432+
419433
for (Runnable nodeHealthCheck : nodeHealthChecks.values()) {
420434
GuardedRunnable.guard(nodeHealthCheck).run();
421435
}

java/src/org/openqa/selenium/grid/node/local/LocalNode.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,10 @@ public boolean isReady() {
377377
@VisibleForTesting
378378
@ManagedAttribute(name = "CurrentSessions")
379379
public int getCurrentSessionCount() {
380+
// we need the exact size, see javadoc of Cache.size
381+
long n = currentSessions.asMap().values().stream().count();
380382
// It seems wildly unlikely we'll overflow an int
381-
return Math.toIntExact(currentSessions.size());
383+
return Math.toIntExact(n);
382384
}
383385

384386
@VisibleForTesting
@@ -1005,6 +1007,9 @@ public HealthCheck getHealthCheck() {
10051007
public void drain() {
10061008
bus.fire(new NodeDrainStarted(getId()));
10071009
draining = true;
1010+
// Ensure the pendingSessions counter will not be decremented by timed out sessions not included
1011+
// in the currentSessionCount and the NodeDrainComplete will be raised to early.
1012+
currentSessions.cleanUp();
10081013
int currentSessionCount = getCurrentSessionCount();
10091014
if (currentSessionCount == 0) {
10101015
LOG.info("Firing node drain complete message");

rust/Cargo.Bazel.lock

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"checksum": "d9285b63a8ce42183b3092dd0140c47d4711a9fa8b5016eaeaa0be37ec80b44b",
2+
"checksum": "87f471e3241881a49b45fd55d0a4e812b38e0ee58bf72dfbc091df4f5fe87ef5",
33
"crates": {
44
"addr2line 0.21.0": {
55
"name": "addr2line",
@@ -2039,16 +2039,79 @@
20392039
"id": "jobserver 0.1.31",
20402040
"target": "jobserver"
20412041
},
2042-
{
2043-
"id": "libc 0.2.168",
2044-
"target": "libc"
2045-
},
20462042
{
20472043
"id": "shlex 1.3.0",
20482044
"target": "shlex"
20492045
}
20502046
],
2051-
"selects": {}
2047+
"selects": {
2048+
"aarch64-apple-darwin": [
2049+
{
2050+
"id": "libc 0.2.168",
2051+
"target": "libc"
2052+
}
2053+
],
2054+
"aarch64-unknown-linux-gnu": [
2055+
{
2056+
"id": "libc 0.2.168",
2057+
"target": "libc"
2058+
}
2059+
],
2060+
"aarch64-unknown-nixos-gnu": [
2061+
{
2062+
"id": "libc 0.2.168",
2063+
"target": "libc"
2064+
}
2065+
],
2066+
"arm-unknown-linux-gnueabi": [
2067+
{
2068+
"id": "libc 0.2.168",
2069+
"target": "libc"
2070+
}
2071+
],
2072+
"i686-unknown-linux-gnu": [
2073+
{
2074+
"id": "libc 0.2.168",
2075+
"target": "libc"
2076+
}
2077+
],
2078+
"powerpc-unknown-linux-gnu": [
2079+
{
2080+
"id": "libc 0.2.168",
2081+
"target": "libc"
2082+
}
2083+
],
2084+
"s390x-unknown-linux-gnu": [
2085+
{
2086+
"id": "libc 0.2.168",
2087+
"target": "libc"
2088+
}
2089+
],
2090+
"x86_64-apple-darwin": [
2091+
{
2092+
"id": "libc 0.2.168",
2093+
"target": "libc"
2094+
}
2095+
],
2096+
"x86_64-unknown-freebsd": [
2097+
{
2098+
"id": "libc 0.2.168",
2099+
"target": "libc"
2100+
}
2101+
],
2102+
"x86_64-unknown-linux-gnu": [
2103+
{
2104+
"id": "libc 0.2.168",
2105+
"target": "libc"
2106+
}
2107+
],
2108+
"x86_64-unknown-nixos-gnu": [
2109+
{
2110+
"id": "libc 0.2.168",
2111+
"target": "libc"
2112+
}
2113+
]
2114+
}
20522115
},
20532116
"edition": "2018",
20542117
"version": "1.1.30"

0 commit comments

Comments
 (0)