Merge pull request #32345 from appsmithorg/cherry-pick/2Apr2024
fix: Scheduling synchronized block on bounded elastic threadpool inst…
This commit is contained in:
commit
3eeb09cddf
|
|
@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
|
@ -103,7 +104,8 @@ public class DatasourceContextServiceCEImpl implements DatasourceContextServiceC
|
|||
// Basically remove entry from both cache maps
|
||||
pluginExecutor.datasourceDestroy(connection);
|
||||
} catch (Exception e) {
|
||||
log.info("Error destroying stale datasource connection", e);
|
||||
log.info(
|
||||
Thread.currentThread().getName() + ": Error destroying stale datasource connection", e);
|
||||
}
|
||||
}
|
||||
datasourceContextMonoMap.remove(datasourceContextIdentifier);
|
||||
|
|
@ -117,7 +119,8 @@ public class DatasourceContextServiceCEImpl implements DatasourceContextServiceC
|
|||
*/
|
||||
if (datasourceContextIdentifier.getDatasourceId() != null
|
||||
&& datasourceContextMonoMap.get(datasourceContextIdentifier) != null) {
|
||||
log.debug("Cached resource context mono exists. Returning the same.");
|
||||
log.debug(Thread.currentThread().getName()
|
||||
+ ": Cached resource context mono exists. Returning the same.");
|
||||
return datasourceContextMonoMap.get(datasourceContextIdentifier);
|
||||
}
|
||||
|
||||
|
|
@ -182,11 +185,11 @@ public class DatasourceContextServiceCEImpl implements DatasourceContextServiceC
|
|||
|
||||
protected Mono<DatasourceContext<?>> createNewDatasourceContext(
|
||||
DatasourceStorage datasourceStorage, DatasourceContextIdentifier datasourceContextIdentifier) {
|
||||
log.debug("Datasource context doesn't exist. Creating connection.");
|
||||
log.debug(Thread.currentThread().getName() + ": Datasource context doesn't exist. Creating connection.");
|
||||
Mono<Plugin> pluginMono =
|
||||
pluginService.findById(datasourceStorage.getPluginId()).cache();
|
||||
|
||||
return pluginMono
|
||||
return (Mono<DatasourceContext<?>>) pluginMono
|
||||
.zipWith(pluginExecutorHelper.getPluginExecutor(pluginMono))
|
||||
.flatMap(tuple2 -> {
|
||||
Plugin plugin = tuple2.getT1();
|
||||
|
|
@ -214,7 +217,9 @@ public class DatasourceContextServiceCEImpl implements DatasourceContextServiceC
|
|||
|
||||
return getCachedDatasourceContextMono(
|
||||
datasourceStorage, plugin, pluginExecutor, monitor, datasourceContextIdentifier);
|
||||
});
|
||||
})
|
||||
// Scheduling on bounded elastic to avoid blocking the main thread
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
}
|
||||
|
||||
public boolean getIsStale(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user