Skip to content

Commit

Permalink
Merge pull request #3884 from katzyn/misc
Browse files Browse the repository at this point in the history
Assorted changes
  • Loading branch information
katzyn committed Sep 1, 2023
2 parents bb70349 + 6bed208 commit 53854b1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
6 changes: 5 additions & 1 deletion h2/src/docsrc/html/changelog.html
Expand Up @@ -21,14 +21,18 @@ <h1>Change Log</h1>

<h2>Next Version (unreleased)</h2>
<ul>
<li>Nothing yet
<li>Issue #3883: Performance regression in 2.2.222
</li>
<li>PR #3879: Require Java 11
</li>
</ul>

<h2>Version 2.2.222 (2023-08-22)</h2>
<ul>
<li>Fixed race condition in MVStore causing database corruption &quot;File corrupted in chunk ###&quot;
</li>
<li>PR #3873: ToC cache is effectively not used after the first shutdown
</li>
<li>Issue #3868: INFORMATION_SCHEMA.SESSIONS.ISOLATION_LEVEL returns isolation level of the current session in all rows
</li>
<li>RP #3865: Add possibility to enable virtual worker threads in TCP, Web, and PG servers on Java 21+
Expand Down
1 change: 0 additions & 1 deletion h2/src/main/META-INF/MANIFEST.MF
Expand Up @@ -57,7 +57,6 @@ Import-Package: javax.crypto,
org.slf4j;version="[1.7.0,1.8.0)";resolution:=optional
Export-Package: org.h2;version="${version}",
org.h2.api;version="${version}",
org.h2.constant;version="${version}",
org.h2.fulltext;version="${version}",
org.h2.jdbc;version="${version}",
org.h2.jdbcx;version="${version}",
Expand Down
10 changes: 10 additions & 0 deletions h2/src/main/org/h2/engine/Session.java
Expand Up @@ -130,6 +130,16 @@ public final void unlock() {
lock.unlock();
}

/**
* Returns whether this session is locked by the current thread.
*
* @return {@code true} if it locked by the current thread, {@code false} if
* it is locked by another thread or is not locked at all
*/
public final boolean isLockedByCurrentThread() {
return lock.isHeldByCurrentThread();
}

/**
* Get the list of the cluster servers for this session.
*
Expand Down
5 changes: 2 additions & 3 deletions h2/src/main/org/h2/engine/SessionLocal.java
Expand Up @@ -714,8 +714,7 @@ private void analyzeTables() {
// On rare occasions it can be called concurrently (i.e. from close())
// without proper locking, but instead of oversynchronizing
// we just skip this optional operation in such case
if (tablesToAnalyze != null &&
Thread.holdsLock(this)) {
if (tablesToAnalyze != null && isLockedByCurrentThread()) {
// take a local copy and clear because in rare cases we can call
// back into markTableForAnalyze while iterating here
HashSet<Table> tablesToAnalyzeLocal = tablesToAnalyze;
Expand Down Expand Up @@ -1503,7 +1502,7 @@ public void waitIfExclusiveModeEnabled() {
if (exclusive == null || exclusive == this) {
break;
}
if (Thread.holdsLock(exclusive)) {
if (exclusive.isLockedByCurrentThread()) {
// if another connection is used within the connection
break;
}
Expand Down
11 changes: 5 additions & 6 deletions h2/src/main/org/h2/jdbc/JdbcConnection.java
Expand Up @@ -86,8 +86,8 @@ public class JdbcConnection extends TraceObject implements Connection, CastDataP

private Session session;
private CommandInterface commit, rollback;
private CommandInterface getReadOnly, getGeneratedKeys;
private CommandInterface setQueryTimeout, getQueryTimeout;
private CommandInterface getReadOnly;
private CommandInterface getQueryTimeout, setQueryTimeout;

private int savepointId;
private String catalog;
Expand Down Expand Up @@ -149,10 +149,10 @@ public JdbcConnection(JdbcConnection clone) {
this.url = clone.url;
this.catalog = clone.catalog;
this.commit = clone.commit;
this.getGeneratedKeys = clone.getGeneratedKeys;
this.getQueryTimeout = clone.getQueryTimeout;
this.getReadOnly = clone.getReadOnly;
this.rollback = clone.rollback;
this.getReadOnly = clone.getReadOnly;
this.getQueryTimeout = clone.getQueryTimeout;
this.setQueryTimeout = clone.setQueryTimeout;
this.watcher = null;
if (clone.clientInfo != null) {
this.clientInfo = new HashMap<>(clone.clientInfo);
Expand Down Expand Up @@ -407,7 +407,6 @@ private void closePreparedCommands() {
commit = closeAndSetNull(commit);
rollback = closeAndSetNull(rollback);
getReadOnly = closeAndSetNull(getReadOnly);
getGeneratedKeys = closeAndSetNull(getGeneratedKeys);
getQueryTimeout = closeAndSetNull(getQueryTimeout);
setQueryTimeout = closeAndSetNull(setQueryTimeout);
}
Expand Down

0 comments on commit 53854b1

Please sign in to comment.