Skip to content

Commit

Permalink
strato concurrent tests
Browse files Browse the repository at this point in the history
1. making strato related tests concurrent as they are timing out on CI at this point
2. adding syncronized to Hotspot snapshot method as it is not thread safe. in particular when we lookup GC name we call PerfStringCounter that calls super PerfByteArrayCounter that resets buffer position to 0. if called concurrently one thread will read the counter resetting position to buffer length and we get BufferUnderflow i.e. race condition
https://github.com/AdoptOpenJDK/openjdk-jdk11u/blob/master/src/java.management/share/classes/sun/management/counter/perf/PerfByteArrayCounter.java#L53
https://github.com/AdoptOpenJDK/openjdk-jdk11u/blob/master/src/java.management/share/classes/sun/management/counter/perf/PerfStringCounter.java#L64

Stack trace:
https://ton.pdxa.twitter.com/scoot/prod_d70f787a-276c-4db8-7e76-36016e1ef442_08fbec44-75f9-482d-7f87-b240c9af3c1e/stdlog

```
generated columnDescs match generated ops(com.twitter.strato.config.compile_tests.ColumnDescTest)
java.nio.BufferUnderflowException
	at java.base/java.nio.DirectByteBuffer.get(DirectByteBuffer.java:294)
	at java.base/java.nio.ByteBuffer.get(ByteBuffer.java:770)
	at java.management/sun.management.counter.perf.PerfByteArrayCounter.byteArrayValue(PerfByteArrayCounter.java:57)
	at java.management/sun.management.counter.perf.PerfStringCounter.stringValue(PerfStringCounter.java:64)
	at java.management/sun.management.counter.perf.PerfStringCounter.getValue(PerfStringCounter.java:58)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at com.twitter.jvm.Hotspot.$anonfun$getGc$5(Hotspot.scala:90)
	at scala.Option.map(Option.scala:230)
	at com.twitter.jvm.Hotspot.$anonfun$getGc$4(Hotspot.scala:90)
	at com.twitter.jvm.Hotspot.$anonfun$getGc$4$adapted(Hotspot.scala:89)
	at scala.Option.flatMap(Option.scala:271)
	at com.twitter.jvm.Hotspot.$anonfun$getGc$2(Hotspot.scala:89)
	at com.twitter.jvm.Hotspot.$anonfun$getGc$2$adapted(Hotspot.scala:88)
	at scala.Option.flatMap(Option.scala:271)
	at com.twitter.jvm.Hotspot.getGc(Hotspot.scala:88)
	at com.twitter.jvm.Hotspot.snap(Hotspot.scala:149)
	at com.twitter.strato.config.loading.ConfigResourceMonitoring$.collect(ConfigResourceMonitoring.scala:55)
	at com.twitter.strato.config.loading.CompiledStratoCatalog.<init>(CompiledStratoCatalog.scala:56)
	at com.twitter.strato.config.loading.CompiledStratoCatalog$.apply(CompiledStratoCatalog.scala:493)
	at com.twitter.strato.test.config.ConfigTestCatalog$$anon$1.mkConfigCatalog(ConfigTestCatalog.scala:333)
	at com.twitter.strato.test.config.ConfigTestCatalog$.apply(ConfigTestCatalog.scala:159)
	at com.twitter.strato.test.config.StratoConfigSuite.mkCatalog(StratoConfigSuite.scala:164)
	at com.twitter.strato.config.compile_tests.ColumnDescTest.$anonfun$new$1(ColumnDescTest.scala:18)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at com.twitter.servo.testing.prop.PropertySuite.$anonfun$test$1(PropertySuite.scala:71)
```

Differential Revision: https://phabricator.twitter.biz/D1188541
  • Loading branch information
Evgenii Slutckii authored and jenkins committed Dec 13, 2024
1 parent 7d74b9c commit 81bab63
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions util-jvm/src/main/scala/com/twitter/jvm/Hotspot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import com.twitter.conversions.StorageUnitOps._
import com.twitter.conversions.DurationOps._
import com.twitter.util.Time
import java.lang.management.ManagementFactory
import java.util.logging.{Level, Logger}
import javax.management.openmbean.{CompositeData, CompositeDataSupport}
import javax.management.{
Notification,
NotificationEmitter,
NotificationListener,
ObjectName,
RuntimeMBeanException
}
import java.util.logging.Level
import java.util.logging.Logger
import javax.management.openmbean.CompositeData
import javax.management.openmbean.CompositeDataSupport
import javax.management.Notification
import javax.management.NotificationEmitter
import javax.management.NotificationListener
import javax.management.ObjectName
import javax.management.RuntimeMBeanException
import javax.naming.OperationNotSupportedException
import scala.jdk.CollectionConverters._
import scala.language.reflectiveCalls
Expand Down Expand Up @@ -115,7 +115,7 @@ class Hotspot extends Jvm {
}
}

def snap: Snapshot = {
def snap: Snapshot = synchronized {
val cs = counters("")
val heap = for {
invocations <- cs.get("sun.gc.collector.0.invocations").map(long)
Expand Down

0 comments on commit 81bab63

Please sign in to comment.