Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-06-10 03:14:11 +0000
committerEike Stepper2020-06-10 03:14:11 +0000
commit4c46695b30588970102507731384bb408d2568d6 (patch)
treef206d11093ea42c22a6cf8e8f3038cf3d00d97e6
parent4d81d551908af31b5956120c5b47217520d52698 (diff)
downloadcdo-4c46695b30588970102507731384bb408d2568d6.tar.gz
cdo-4c46695b30588970102507731384bb408d2568d6.tar.xz
cdo-4c46695b30588970102507731384bb408d2568d6.zip
[564150] [DB] TimeoutRuntimeException: Schema "repo1" could not be locked...
https://bugs.eclipse.org/bugs/show_bug.cgi?id=564150
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java132
1 files changed, 72 insertions, 60 deletions
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
index ab355e2112..9a52e1dd9f 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
@@ -242,94 +242,106 @@ public final class DBDatabase extends SetContainer<IDBConnection> implements IDB
}
}
+ boolean success = false;
Object token = null;
SchemaAccess schemaAccess = null;
- synchronized (schemaAccessQueue)
+ try
{
- if (write)
- {
- schemaAccess = createWriteSchemaAccess();
- token = schemaAccess;
- schemaAccessQueue.addLast(schemaAccess);
- ++waitingSchemaWriters;
- }
- else
+ synchronized (schemaAccessQueue)
{
- if (waitingSchemaWriters == 0 && !schemaAccessQueue.isEmpty())
+ if (write)
{
- schemaAccess = schemaAccessQueue.getFirst();
- if (schemaAccess instanceof ReadSchemaAccess)
- {
- ReadSchemaAccess readSchemaAccess = (ReadSchemaAccess)schemaAccess;
- token = readSchemaAccess.addReader();
- }
- else
+ schemaAccess = createWriteSchemaAccess();
+ token = schemaAccess;
+ schemaAccessQueue.addLast(schemaAccess);
+ ++waitingSchemaWriters;
+ }
+ else
+ {
+ if (waitingSchemaWriters == 0 && !schemaAccessQueue.isEmpty())
{
- schemaAccess = null;
+ schemaAccess = schemaAccessQueue.getFirst();
+ if (schemaAccess instanceof ReadSchemaAccess)
+ {
+ ReadSchemaAccess readSchemaAccess = (ReadSchemaAccess)schemaAccess;
+ token = readSchemaAccess.addReader();
+ }
+ else
+ {
+ schemaAccess = null;
+ }
}
- }
- if (schemaAccess == null)
- {
- ReadSchemaAccess readSchemaAccess = createReadSchemaAccess();
- token = readSchemaAccess.addReader();
+ if (schemaAccess == null)
+ {
+ ReadSchemaAccess readSchemaAccess = createReadSchemaAccess();
+ token = readSchemaAccess.addReader();
- schemaAccess = readSchemaAccess;
- schemaAccessQueue.addLast(schemaAccess);
+ schemaAccess = readSchemaAccess;
+ schemaAccessQueue.addLast(schemaAccess);
+ }
}
}
- }
- long end = System.currentTimeMillis() + TIMEOUT_SCHEMA_ACCESS;
+ long end = System.currentTimeMillis() + TIMEOUT_SCHEMA_ACCESS;
- for (;;)
- {
- synchronized (schemaAccessQueue)
+ for (;;)
{
- SchemaAccess activeSchemaAccess = schemaAccessQueue.getFirst();
- if (activeSchemaAccess == schemaAccess)
+ synchronized (schemaAccessQueue)
{
- if (write)
+ SchemaAccess activeSchemaAccess = schemaAccessQueue.getFirst();
+ if (activeSchemaAccess == schemaAccess)
{
- --waitingSchemaWriters;
- }
-
- return token;
- }
+ if (write)
+ {
+ --waitingSchemaWriters;
+ }
- try
- {
- schemaAccessQueue.wait(1000L);
- }
- catch (InterruptedException ex)
- {
- Thread.currentThread().interrupt();
- throw WrappedException.wrap(ex);
- }
+ success = true;
+ return token;
+ }
- if (System.currentTimeMillis() >= end)
- {
- StringBuilder builder = new StringBuilder("Schema " + schema.getName() + " could not be locked for " + (write ? "write" : "read") + " access within "
- + TIMEOUT_SCHEMA_ACCESS + " milliseconds. Schema access queue:" + StringUtil.NL);
- int i = 0;
+ try
+ {
+ schemaAccessQueue.wait(1000L);
+ }
+ catch (InterruptedException ex)
+ {
+ Thread.currentThread().interrupt();
+ throw WrappedException.wrap(ex);
+ }
- for (SchemaAccess blockingAccess : schemaAccessQueue)
+ if (System.currentTimeMillis() >= end)
{
- if (blockingAccess == schemaAccess)
+ StringBuilder builder = new StringBuilder("Schema " + schema.getName() + " could not be locked for " + (write ? "write" : "read")
+ + " access within " + TIMEOUT_SCHEMA_ACCESS + " milliseconds. Schema access queue:" + StringUtil.NL);
+ int i = 0;
+
+ for (SchemaAccess blockingAccess : schemaAccessQueue)
{
- builder.append("--> ");
+ if (blockingAccess == schemaAccess)
+ {
+ builder.append("--> ");
+ }
+
+ builder.append(i++);
+ builder.append(": ");
+ builder.append(blockingAccess);
}
- builder.append(i++);
- builder.append(": ");
- builder.append(blockingAccess);
+ throw new TimeoutRuntimeException(builder.toString());
}
-
- throw new TimeoutRuntimeException(builder.toString());
}
}
}
+ finally
+ {
+ if (!success)
+ {
+ schemaAccessQueue.remove(schemaAccess);
+ }
+ }
}
public void endSchemaAccess(Object token)

Back to the top