oracle-r2dbc icon indicating copy to clipboard operation
oracle-r2dbc copied to clipboard

IllegalStateException: A thread that is executing an IO task has attempted to await the completion of itself. This is a deadlock.

Open Michael-A-McMahon opened this issue 1 year ago • 0 comments

After updating to 1.3.0 users may see the error listed in the title of this issue. In most cases it can be resolved by setting DEFAULT_LOB_PREFETCH_SIZE to the value of 1000000000 (1GB).

The DEFAULT_LOB_PREFETCH_SIZE may be configured using ConnectionFactoryOptions.Builder:

ConnectionFactory example() {
  ConnectionFactoryOptions options =
    ConnectionFactoryOptions.builder()
      // Allow queries to allocate up to 1GB for each BLOB/CLOB value
      .option(OracleR2dbcOptions.DEFAULT_LOB_PREFETCH_SIZE, "1000000000")
      // Configure other options as usual
      .option(DRIVER, "oracle")
      .option(HOST, "localhost")
      .option(PORT, 1521)
      .option(DATABASE, "dbName")
      .option(USER, System.getenv("DB_USER"))
      .option(PASSWORD, System.getenv("DB_PASSWORD"))
      .build();

  return ConnectionFactories.get(options);
}

The option may also be configured as a URL parameter:

ConnectionFactory example() {
  ConnectionFactoryOptions options = ConnectionFactoryOptions.parse(
    "r2dbc:oracle://localhost:1521/dbName?oracle.jdbc.defaultLobPrefetchSize=1000000000")
    .mutate()
    // Configure other options as usual
    .option(USER, System.getenv("DB_USER"))
    .option(PASSWORD, System.getenv("DB_PASSWORD"))
    .build();
  return ConnectionFactories.get(options);
}

More resources on configuring a prefetch and consuming LOBs: Oracle R2DBC Documentation Optimized processing of your 'not-so-large' Large Objects (LOBs) with Value LOBs

The root cause of this issue is a defect in the 23.7 release of Oracle JDBC (bug #37347553). I have already made a fix for that and will request for its inclusion in the 23.8 release.

In Oracle R2DBC, there is a defect in how the default LOB prefetch size is set. It is set to 1MB, when it should be set to 1GB. A fix for that will go into the next Oracle R2DBC release. Once it is resolved, explicitly setting 1GB will no longer be necessary.

Michael-A-McMahon avatar Dec 03 '24 23:12 Michael-A-McMahon