Skip to content

Commit

Permalink
Locking bugfixes and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Hafner committed Dec 3, 2024
1 parent 8bcb170 commit f6b45d6
Show file tree
Hide file tree
Showing 4 changed files with 381 additions and 309 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void upgradeToExclusive( Transaction transaction ) throws InterruptedExc
}
long count = owners.remove( transaction );
while ( !owners.isEmpty() ) {
//DeadlockHandler.INSTANCE.addAndResolveDeadlock(this, transaction, owners.keySet() );
DeadlockHandler.INSTANCE.addAndResolveDeadlock(this, transaction, owners.keySet() );
concurrencyCondition.await();
}
isExclusive = true;
Expand Down Expand Up @@ -163,12 +163,15 @@ private boolean hasWaitingTransactions() {


private void printAcquiredInfo( String message, Transaction transaction ) {

LOGGER.info ( MessageFormat.format(
"{0}, TX: {1}, L: {2}",
message,
transaction,
this
) );



}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

package org.polypheny.db.transaction;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.polypheny.db.TestHelper;
import org.polypheny.db.catalog.Catalog;
import org.polypheny.db.languages.LanguageManager;
Expand All @@ -38,6 +35,7 @@ public static List<ExecutedContext> executeStatement( String query, String langu


public static List<ExecutedContext> executeStatement( String query, String languageName, String namespaceName, Transaction transaction, TestHelper testHelper ) {
System.out.println( query + ":::" + transaction );
QueryLanguage language = QueryLanguage.from( languageName );
long namespaceId = Catalog.getInstance().getSnapshot().getNamespace( namespaceName ).orElseThrow().getId();
QueryContext context = QueryContext.builder()
Expand All @@ -50,26 +48,4 @@ public static List<ExecutedContext> executeStatement( String query, String langu
return LanguageManager.getINSTANCE().anyQuery( context.addTransaction( transaction ) );
}


public static void executePermutations( List<String> executions, Map<String, Runnable> operations, Set<Session> sessions, Runnable setup, Runnable cleanup ) {
executions.forEach( sequence -> {
System.out.println( "Executing:" + sequence );
setup.run();
Arrays.stream( sequence.split( " " ) )
.forEach(
operations::get );
sessions.forEach( session -> {
try {
if (!session.awaitCompletion()) {
throw new RuntimeException( "Session did not complete properly." );
}
} catch ( InterruptedException e ) {
throw new RuntimeException( "Execution of operation sequence failed.", e );
}
} );
cleanup.run();
} );

}

}
Loading

0 comments on commit f6b45d6

Please sign in to comment.