Skip to content

Commit

Permalink
Cache DeadLock Detection test move from org.eclipse.persistence.jpa.j…
Browse files Browse the repository at this point in the history
…se.test into new org.eclipse.persistence.jpa.testapps.deadlock.diagnostic Maven module

There is move into new Maven module some test refactor and new test for WriteLockManager.acquireLocksForClone(...) method call and logging.

Signed-off-by: Radek Felcman <[email protected]>
  • Loading branch information
rfelcman committed Nov 19, 2024
1 parent 38f4453 commit 8bc344d
Show file tree
Hide file tree
Showing 18 changed files with 690 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public class WriteLockManager {
private final Lock instancePrevailingQueueLock = new ReentrantLock();
private final Condition toWaitOnLockCondition = toWaitOnLock.newCondition();

private static final String ACQUIRE_LOCK_FOR_CLONE_METHOD_NAME = WriteLockManager.class.getName() + ".acquireLocksForClone(...)";

public WriteLockManager() {
this.prevailingQueue = new ExposedNodeLinkedList();
}
Expand Down Expand Up @@ -170,9 +172,8 @@ public Map acquireLocksForClone(Object objectForClone, ClassDescriptor descripto
// of the concurrency manager that we use for creating the massive log dump
// to indicate that the current thread is now stuck trying to acquire some arbitrary
// cache key for writing
StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[1];
lastCacheKeyWeNeededToWaitToAcquire = toWaitOn;
lastCacheKeyWeNeededToWaitToAcquire.putThreadAsWaitingToAcquireLockForWriting(currentThread, stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + "(...)");
lastCacheKeyWeNeededToWaitToAcquire.putThreadAsWaitingToAcquireLockForWriting(currentThread, ACQUIRE_LOCK_FOR_CLONE_METHOD_NAME);

// Since we know this one of those methods that can appear in the dead locks
// we threads frozen here forever inside of the wait that used to have no timeout
Expand Down
26 changes: 1 addition & 25 deletions jpa/eclipselink.jpa.test.jse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<scope>test</scope>
</dependency>
<!--ASM Implementations-->
<!--EclipseLink ASM Implementation-->
<dependency>
Expand Down Expand Up @@ -210,32 +200,18 @@
</configuration>
<executions>
<execution>
<id>test-jpa-jse-without-deadlock</id>
<id>test-jpa-jse</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<skipTests>${test-skip-jpa-jse}</skipTests>
<reportNameSuffix>test-jpa-jse</reportNameSuffix>
<excludes>
<exclude>CacheDeadLockDetectionTest*</exclude>
</excludes>
<includes>
<include>*.Test*</include>
</includes>
</configuration>
</execution>
<execution>
<id>test-jpa-jse-deadlock</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>CacheDeadLockDetectionTest*</include>
</includes>
</configuration>
</execution>
<execution>
<id>verify-integration-tests</id>
<goals>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,4 @@
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties></properties>
</persistence-unit>

<persistence-unit name="cachedeadlockdetection-pu" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.eclipse.persistence.jpa.test.cachedeadlock.model.CacheDeadLockDetectionMaster</class>
<class>org.eclipse.persistence.jpa.test.cachedeadlock.model.CacheDeadLockDetectionDetail</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.concurrency.manager.waittime" value="1"/>
<property name="eclipselink.concurrency.manager.maxsleeptime" value="2"/>
<property name="eclipselink.concurrency.manager.maxfrequencytodumptinymessage" value="800"/>
<property name="eclipselink.concurrency.manager.maxfrequencytodumpmassivemessage" value="1000"/>
<property name="eclipselink.concurrency.manager.build.object.complete.waittime" value="5"/>
<property name="eclipselink.concurrency.manager.allow.readlockstacktrace" value="true"/>
<property name="eclipselink.concurrency.manager.allow.concurrencyexception" value="true"/>
<property name="eclipselink.concurrency.manager.allow.interruptedexception" value="true"/>
</properties>
</persistence-unit>

<persistence-unit name="cachedeadlocksemaphore-pu" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.eclipse.persistence.jpa.test.cachedeadlock.model.CacheDeadLockDetectionMaster</class>
<class>org.eclipse.persistence.jpa.test.cachedeadlock.model.CacheDeadLockDetectionDetail</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.concurrency.manager.waittime" value="1"/>
<property name="eclipselink.concurrency.manager.maxsleeptime" value="2"/>
<property name="eclipselink.concurrency.manager.maxfrequencytodumptinymessage" value="1000"/>
<property name="eclipselink.concurrency.manager.maxfrequencytodumpmassivemessage" value="2000"/>
<property name="eclipselink.concurrency.manager.allow.readlockstacktrace" value="true"/>
<property name="eclipselink.concurrency.manager.allow.concurrencyexception" value="true"/>
<property name="eclipselink.concurrency.manager.allow.interruptedexception" value="true"/>
<property name="eclipselink.concurrency.manager.object.building.semaphore" value="true"/>
<property name="eclipselink.concurrency.manager.object.building.no.threads" value="5"/>
<property name="eclipselink.concurrency.manager.write.lock.manager.semaphore" value="true"/>
<property name="eclipselink.concurrency.manager.write.lock.manager.no.threads" value="6"/>
<property name="eclipselink.concurrency.semaphore.max.time.permit" value="7"/>
<property name="eclipselink.concurrency.semaphore.log.timeout" value="8"/>
</properties>
</persistence-unit>

</persistence>
109 changes: 109 additions & 0 deletions jpa/eclipselink.jpa.testapps/jpa.test.diagnostic.deadlock/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0,
or the Eclipse Distribution License v. 1.0 which is available at
http://www.eclipse.org/org/documents/edl-v10.php.
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>org.eclipse.persistence.jpa.testapps</artifactId>
<groupId>org.eclipse.persistence</groupId>
<version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>org.eclipse.persistence.jpa.testapps.deadlock.diagnostic</artifactId>

<name>Test - deadlock diagnostic framework</name>

<properties>
<argLine/>
</properties>

<dependencies>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!--Resolve dependencies into Maven properties like ${org.eclipse.persistence:org.eclipse.persistence.jpa:jar} for JPA module-->
<execution>
<id>get-test-classpath-to-properties</id>
<phase>process-test-classes</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.carlspring.maven</groupId>
<artifactId>derby-maven-plugin</artifactId>
<executions>
<execution>
<id>start-derby</id>
<phase>process-test-classes</phase>
</execution>
<execution>
<id>stop-derby</id>
<phase>prepare-package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<configuration>
<argLine>-javaagent:${org.eclipse.persistence:org.eclipse.persistence.jpa:jar} @{argLine}</argLine>
<includes>
<include>CacheDeadLockDetectionTest*</include>
</includes>
</configuration>
</execution>
<execution>
<id>dead-lock-managers-test</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>CacheDeadLockManagersTest*</include>
</includes>
<systemPropertyVariables>
<!--Following system properties must be initialized again as systemPropertyVariables reset environment.-->
<db.driver>${db.driver}</db.driver>
<db.url>${db.url}</db.url>
<db.user>${db.user}</db.user>
<db.pwd>${db.pwd}</db.pwd>
<db.platform>${db.platform}</db.platform>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 8bc344d

Please sign in to comment.