Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
db67d8e
Debug freezing test on CI.
AlexeyKuznetsov-DD Aug 11, 2025
b4d7fd6
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 12, 2025
025e232
Trying to reproduce.
AlexeyKuznetsov-DD Aug 12, 2025
b62fc03
Trying to reproduce.
AlexeyKuznetsov-DD Aug 12, 2025
d6d4454
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 13, 2025
835f313
Trying to reproduce.
AlexeyKuznetsov-DD Aug 13, 2025
5892ac5
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 13, 2025
7cafe75
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 14, 2025
01b34c3
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 14, 2025
a1fae6a
Updated flaky tests.
AlexeyKuznetsov-DD Aug 14, 2025
375a9ff
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 14, 2025
60deecd
Trying to reproduce.
AlexeyKuznetsov-DD Aug 14, 2025
0a415ca
Trying to reproduce.
AlexeyKuznetsov-DD Aug 14, 2025
4cfbfd7
Merge branch 'alexeyk/apache-http-5-flaky-tests' into alexeyk/debug-c…
AlexeyKuznetsov-DD Aug 14, 2025
7a263b9
Trying to reproduce.
AlexeyKuznetsov-DD Aug 14, 2025
fac9597
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 15, 2025
26d7a12
Trying to reproduce.
AlexeyKuznetsov-DD Aug 15, 2025
9179563
Trying to reproduce.
AlexeyKuznetsov-DD Aug 15, 2025
16cf188
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 18, 2025
435d111
Trying to reproduce.
AlexeyKuznetsov-DD Aug 18, 2025
fdb23a4
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 19, 2025
9232258
Trying to fix with `useStrictTraceWrites == false`
AlexeyKuznetsov-DD Aug 19, 2025
2c0c4ce
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 19, 2025
118a0ef
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 19, 2025
d6ce19f
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 20, 2025
ba2a706
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 21, 2025
6f7706b
Trying to reproduce.
AlexeyKuznetsov-DD Aug 21, 2025
b8f1dd3
Rolled back `useStrictTraceWrites == false`
AlexeyKuznetsov-DD Aug 21, 2025
4429e5d
Refactored dump logic: start thread in advance and sleep.
AlexeyKuznetsov-DD Aug 21, 2025
ce809d7
Trying to reproduce
AlexeyKuznetsov-DD Aug 21, 2025
79204d9
Refactored thread dump logic
AlexeyKuznetsov-DD Aug 22, 2025
d777c3c
Refactored thread dump logic
AlexeyKuznetsov-DD Aug 22, 2025
dd2ea8c
Trying to reproduce
AlexeyKuznetsov-DD Aug 22, 2025
b0de3f5
Merge branch 'master' into alexeyk/debug-ci-freeze
AlexeyKuznetsov-DD Aug 22, 2025
bb06758
Attempt to get dump via gradle
AlexeyKuznetsov-DD Aug 22, 2025
556e780
Fixed codenarc.
AlexeyKuznetsov-DD Aug 22, 2025
f55ccb5
Trying to reproduce.
AlexeyKuznetsov-DD Aug 23, 2025
2d4aaa6
Merge branch 'master' into alexeyk/debug-ci-freeze-gradle
AlexeyKuznetsov-DD Aug 23, 2025
f2ec317
Trying to reproduce.
AlexeyKuznetsov-DD Aug 23, 2025
161991a
Trying to reproduce with heap dump.
AlexeyKuznetsov-DD Aug 23, 2025
cd1c49c
Skip non-gradle heap dumps
AlexeyKuznetsov-DD Aug 23, 2025
331e308
Trying to reproduce.
AlexeyKuznetsov-DD Aug 23, 2025
a627099
Trying to reproduce.
AlexeyKuznetsov-DD Aug 25, 2025
4e2c0eb
Merge branch 'master' into alexeyk/debug-ci-freeze-gradle
AlexeyKuznetsov-DD Aug 25, 2025
dbe7361
Merge branch 'master' into alexeyk/debug-ci-freeze-gradle
AlexeyKuznetsov-DD Aug 25, 2025
255e66c
Trying to reproduce.
AlexeyKuznetsov-DD Aug 25, 2025
5ebc09c
Limit Heap dumps only for Gradle Test Executors.
AlexeyKuznetsov-DD Aug 25, 2025
e26f582
Merge branch 'master' into alexeyk/debug-ci-freeze-gradle
AlexeyKuznetsov-DD Aug 26, 2025
19e5450
Merge branch 'master' into alexeyk/debug-ci-freeze-gradle
AlexeyKuznetsov-DD Aug 27, 2025
714fdb9
Minor refactoring.
AlexeyKuznetsov-DD Aug 27, 2025
f382692
Minor refactoring.
AlexeyKuznetsov-DD Aug 27, 2025
be9dae2
Minor refactoring.
AlexeyKuznetsov-DD Aug 27, 2025
d920e92
Fixed typo
AlexeyKuznetsov-DD Aug 27, 2025
a927c0b
Merge branch 'master' into alexeyk/debug-ci-freeze-gradle
AlexeyKuznetsov-DD Aug 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

ext {
minJavaVersionForTests = JavaVersion.VERSION_21
// Structured concurrency is a preview feature in Java 21. Methods (e.g. ShutdownOnFailure) used in this instrumentation test are no longer available in Java 25, so we set the max version to 24.
Expand Down Expand Up @@ -58,3 +61,65 @@ compileJava.configure {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType(Test).configureEach {
doFirst {
// This manipulation is requred to move files into folder
// that will be collected by `collect_reports.sh` script.
String buildDir = layout.buildDirectory.asFile.get().absolutePath.replace("dd-trace-java/dd-java-agent",
"dd-trace-java/workspace/dd-java-agent")

def dupmsDir = new File(buildDir, "dumps")
dupmsDir.mkdirs()

// Scheduler to execute logic that will dump threads and heap
def scheduler = Executors.newSingleThreadScheduledExecutor({ r ->
Thread t = new Thread(r, "dump-scheduler")
t.setDaemon(true)
return t
})

// Schedule the dump job:
def future = scheduler.schedule({
try {
def threadDumpFile = new File(dupmsDir, "${System.currentTimeMillis()}-thread-dump.log")

new ProcessBuilder("jcmd", "0", "Thread.print", "-l")
.redirectErrorStream(true)
.redirectOutput(threadDumpFile)
.start().waitFor()

// Collect PIDs of all Java processes:
def jvmProcesses = "jcmd -l".execute().text.readLines()
jvmProcesses.each { p ->
// Process only test executors.
if (!p.contains("Gradle Test Executor")) {
return
}

def pid = p.substring(0, p.indexOf(' '))
def heapDumpFile = "${dupmsDir.absolutePath}/${System.currentTimeMillis()}-${pid}.hprof"
def cmd = "jcmd ${pid} GC.heap_dump ${heapDumpFile}"
cmd.execute().waitFor()
}
} catch (Throwable t) {
logger.warn("Dumping failed: ${t.message}", t)
} finally {
scheduler.shutdown()
}
}, 60, TimeUnit.SECONDS) // You can adjust this line with required delay.

// Store handles for cancellation in doLast:
ext.dumpFuture = future
ext.dumpScheduler = scheduler
}

doLast {
// Cancel if task completed faster than specified timeout.
try {
ext.dumpFuture?.cancel(false)
} finally {
ext.dumpScheduler?.shutdownNow()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import static datadog.trace.agent.test.utils.TraceUtils.runnableUnderTrace
import static java.time.Instant.now

class StructuredConcurrencyTest extends AgentTestRunner {
@Override
boolean useStrictTraceWrites() {
// TODO: Monitor in CI to validate fix effectiveness against freezes.
return false
}

/**
* Tests the structured task scope with a single task.
*/
Expand Down
64 changes: 64 additions & 0 deletions dd-java-agent/instrumentation/lettuce-4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

muzzle {
pass {
Expand All @@ -20,3 +22,65 @@ dependencies {

latestDepTestImplementation group: 'biz.paluch.redis', name: 'lettuce', version: '4.+'
}

tasks.withType(Test).configureEach {
doFirst {
// This manipulation is requred to move files into folder
// that will be collected by `collect_reports.sh` script.
String buildDir = layout.buildDirectory.asFile.get().absolutePath.replace("dd-trace-java/dd-java-agent",
"dd-trace-java/workspace/dd-java-agent")

def dupmsDir = new File(buildDir, "dumps")
dupmsDir.mkdirs()

// Scheduler to execute logic that will dump threads and heap
def scheduler = Executors.newSingleThreadScheduledExecutor({ r ->
Thread t = new Thread(r, "dump-scheduler")
t.setDaemon(true)
return t
})

// Schedule the dump job:
def future = scheduler.schedule({
try {
def threadDumpFile = new File(dupmsDir, "${System.currentTimeMillis()}-thread-dump.log")

new ProcessBuilder("jcmd", "0", "Thread.print", "-l")
.redirectErrorStream(true)
.redirectOutput(threadDumpFile)
.start().waitFor()

// Collect PIDs of all Java processes:
def jvmProcesses = "jcmd -l".execute().text.readLines()
jvmProcesses.each { p ->
// Process only test executors.
if (!p.contains("Gradle Test Executor")) {
return
}

def pid = p.substring(0, p.indexOf(' '))
def heapDumpFile = "${dupmsDir.absolutePath}/${System.currentTimeMillis()}-${pid}.hprof"
def cmd = "jcmd ${pid} GC.heap_dump ${heapDumpFile}"
cmd.execute().waitFor()
}
} catch (Throwable t) {
logger.warn("Dumping failed: ${t.message}", t)
} finally {
scheduler.shutdown()
}
}, 60, TimeUnit.SECONDS) // You can adjust this line with required delay.

// Store handles for cancellation in doLast:
ext.dumpFuture = future
ext.dumpScheduler = scheduler
}

doLast {
// Cancel if task completed faster than specified timeout.
try {
ext.dumpFuture?.cancel(false)
} finally {
ext.dumpScheduler?.shutdownNow()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,4 @@ abstract class Lettuce4ClientTestBase extends VersionedNamingTestBase {
redisClient.shutdown()
redisServer.stop()
}

@Override
boolean useStrictTraceWrites() {
// TODO: Monitor in CI to validate fix effectiveness against freezes.
return false
}
}