Skip to content

Commit

Permalink
Remove/revert debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Aug 29, 2024
1 parent cdc52dd commit 028552f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
18 changes: 9 additions & 9 deletions dbms/src/main/java/org/polypheny/db/transaction/LockManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class LockManager {
public static final LockManager INSTANCE = new LockManager();

private boolean isExclusive = false;
private final Set<Long> owners = new HashSet<>();
private final Set<Xid> owners = new HashSet<>();
private final ConcurrentLinkedQueue<Thread> waiters = new ConcurrentLinkedQueue<>();
private final ReentrantLock lock = new ReentrantLock();
private final Condition condition = lock.newCondition();
Expand All @@ -54,7 +54,7 @@ public void lock( LockMode mode, @NonNull Transaction transaction ) throws Deadl
if ( owners.isEmpty() ) {
handleLockOrThrow( mode, transaction );
return;
} else if ( owners.contains( transaction.getId() ) && (mode == LockMode.SHARED || isExclusive) ) {
} else if ( owners.contains( transaction.getXid() ) && (mode == LockMode.SHARED || isExclusive) ) {
log.debug( "already locked {}", transaction.getXid() );
// already have the required lock
return;
Expand All @@ -69,7 +69,7 @@ public void lock( LockMode mode, @NonNull Transaction transaction ) throws Deadl
lock.lock();
try {
while ( waiters.peek() != thread ) {
log.debug( "wait {} ", transaction.getId() );
log.debug( "wait {} ", transaction.getXid() );
boolean successful = condition.await( RuntimeConfig.LOCKING_MAX_TIMEOUT_SECONDS.getInteger(), TimeUnit.SECONDS );
if ( !successful ) {
cleanup( thread );
Expand Down Expand Up @@ -120,23 +120,23 @@ private void handleLockOrThrow( LockMode mode, @NotNull Transaction transaction
private synchronized boolean handleSimpleLock( @NonNull LockMode mode, Transaction transaction ) {
if ( mode == LockMode.EXCLUSIVE ) {
// get w
if ( owners.isEmpty() || (owners.size() == 1 && owners.contains( transaction.getId() )) ) {
if ( owners.isEmpty() || (owners.size() == 1 && owners.contains( transaction.getXid() )) ) {
if ( isExclusive ) {
log.debug( "lock already exclusive" );
return true;
}

log.debug( "x lock {}", transaction.getXid() );
isExclusive = true;
owners.add( transaction.getId() );
owners.add( transaction.getXid() );
return true;
}

} else {
// get r
if ( !isExclusive || owners.contains( transaction.getId() ) ) {
if ( !isExclusive || owners.contains( transaction.getXid() ) ) {
log.debug( "r lock {}", transaction.getXid() );
owners.add( transaction.getId() );
owners.add( transaction.getXid() );
return true;
}

Expand All @@ -158,7 +158,7 @@ private void signalAll() {


public synchronized void unlock( @NonNull Transaction transaction ) {
if ( !owners.contains( transaction.getId() ) ) {
if ( !owners.contains( transaction.getXid() ) ) {
log.debug( "Transaction is no owner" );
return;
}
Expand All @@ -167,7 +167,7 @@ public synchronized void unlock( @NonNull Transaction transaction ) {
isExclusive = false;
}
log.debug( "release {}", transaction.getXid() );
owners.remove( transaction.getId() );
owners.remove( transaction.getXid() );

// wake up waiters
signalAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,6 @@ private Response prepareIndexedStatement( PrepareStatementRequest request, Respo
private Response executeIndexedStatement( ExecuteIndexedStatementRequest request, ResponseMaker<StatementResult> responseObserver ) {
PIClient client = getClient();
PIPreparedIndexedStatement statement = client.getStatementManager().getIndexedPreparedStatement( request.getStatementId() );
if ( statement != null && statement.getTransaction() != null && client.getCurrentTransaction() != null && statement.getTransaction().getId() != client.getCurrentTransaction().getId() ) {
if ( !statement.getTransaction().isActive() ){ // todo @gartens @tobiashafner fix
log.debug( "This definitely should not happen! {}", statement.getTransaction().getId() );
statement.setStatement( client.getCurrentTransaction().createStatement() );
}
}
int fetchSize = request.hasFetchSize()
? request.getFetchSize()
: PropertyUtils.DEFAULT_FETCH_SIZE;
Expand Down

0 comments on commit 028552f

Please sign in to comment.