postgresql - JackRabbit OAK:在 postgresql 中生成空闲 DB 事务
问题描述
我们在我们的项目中使用 JackRabbit OAK 实现与 postgresql DB 集成。下面是使用 postgresql 创建存储库的代码片段。
private static Repository createRepo(final Map<String, String> dbDetails)
throws DataStoreException {
try {
final RDBOptions options =
new RDBOptions().tablePrefix(dbDetails.get(DB_TABLE_PREFIX)).dropTablesOnClose(
false);
final DataSource ds =
RDBDataSourceFactory.forJdbcUrl(
dbDetails.get("db_URL"),
dbDetails.get("db_User"),
dbDetails.get("db_Password"));
final Properties properties = buildS3Properties(dbDetails);
final S3DataStore s3DataStore = buildS3DataStore(properties);
final DataStoreBlobStore dataStoreBlobStore = new DataStoreBlobStore(s3DataStore); // NOSONAR
final Whiteboard wb = new DefaultWhiteboard();
bapRegistration =
wb.register(
BlobAccessProvider.class,
(BlobAccessProvider) dataStoreBlobStore,
properties);
documentNodeStore =
new RDBDocumentNodeStoreBuilder()
.setBlobStore(dataStoreBlobStore)
.setBundlingDisabled(true)
.setRDBConnection(ds, options)
.build();
repository = new Jcr(documentNodeStore).with(wb).createRepository();
return repository;
} catch (final DataStoreException e) {
log.error("Error." + e);
throw new DataStoreException("Error");
}
}
我们的应用程序运行良好,但是当我们检查 postgresql 数据库统计信息时,我们可以看到在数据库端创建了许多空闲或空闲的事务连接。
xxxxx | 6 days 05:56:12.75259 | select ID, MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, VERSION, SDTYPE, SDMAXREVTIME, DATA, BDATA from mango_NODES where SDTYPE in ($1, $2, $3) and SDMAXREVTIME <= $4 and VERSION >= $5 | idle in transaction
xxxxx | 5 days 22:05:38.855597 | select ID, MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, VERSION, SDTYPE, SDMAXREVTIME, DATA, BDATA from mango_NODES where DELETEDONCE = $1 and MODIFIED < $2 and MODIFIED >= $3 | idle in transaction
xxxxx | 25 days 23:02:38.845462 | SET application_name = 'PostgreSQL JDBC Driver' | idle
xxxxx | 25 days 23:02:38.829477 | SET application_name = 'PostgreSQL JDBC Driver' | idle
xxxxx | 5 days 06:21:58.12896 | COMMIT | idle
xxxxx | 6 days 15:15:29.972181 | select ID, MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, VERSION, SDTYPE, SDMAXREVTIME, DATA, BDATA from mango_NODES where SDTYPE in ($1, $2, $3) and SDMAXREVTIME <= $4 and VERSION >= $5 | idle in transaction
xxxxx | 6 days 19:27:06.133048 | select ID, MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, VERSION, SDTYPE, SDMAXREVTIME, DATA, BDATA from mango_NODES where DELETEDONCE = $1 and MODIFIED < $2 and MODIFIED >= $3 | idle in transaction
xxxxx | 6 days 12:17:47.585068 | select ID, MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, VERSION, SDTYPE, SDMAXREVTIME, DATA, BDATA from mango_NODES where DELETEDONCE = $1 and MODIFIED < $2 and MODIFIED >= $3 | idle in transaction
xxxxx | 1 day 20:54:32.433188 | SET application_name = 'PostgreSQL JDBC Driver'
postgres xxxxx 4210 1 Nov18 ? 01:51:26 postgres: main: cms cms_prod 10.x.x.x(xxxxx) idle in transaction
postgres xxxxx 4210 0 Nov18 ? 00:42:05 postgres: main: cms cms_prod 10.x.x.x(xxxxx) idle in transaction
postgres xxxxx 4210 3 Nov18 ? 06:18:13 postgres: main: cms cms_prod 10.x.x.x(xxxxx) idle
postgres xxxxx 4210 3 Nov18 ? 05:46:57 postgres: main: cms cms_prod 10.x.x.x(xxxxx) idle
postgres xxxxx 4210 0 Nov18 ? 00:24:22 postgres: main: cms cms_prod 10.x.x.x(xxxxx) idle in transaction
postgres xxxxx 4210 0 Nov18 ? 00:08:08 postgres: main: cms cms_prod 10.x.x.x(xxxxx) idle in transaction
postgres xxxxx 4210 0 Nov18 ? 00:27:06 postgres: main: cms cms_prod 10.x.x.x(xxxxx) idle in transaction
postgres xxxxx 4210 0 Nov17 ? 00:00:00 postgres: main: cms cms_prod 10.xx.xxx.xx(xxxxx) idle
如何避免 JackRabbit 橡木实现中的这种空闲连接?我们可以直接杀死那些空闲的连接吗?
解决方案
推荐阅读
- node.js - 寻找一种将节点应用程序打包到作为 Windows 服务运行的独立 Windows 可执行文件的方法
- android - 将字节转换为 base64 字符串时结果得到 \n
- c# - 将 Tiff 内存流转换为位图
- nginx - 三分之一的 Nginx 路由忽略上游服务器
- autocomplete - 我可以覆盖 dijit/form/_AutoCompleterMixin 以匹配字符串的任何部分,而不仅仅是开始字符串?
- python - 如何在countVectorizer中将带小数或逗号的数字视为一个单词
- java - 获取仅包含 JSON 的日志
- c++ - 使用 cppcheck 进行多行压缩
- php - 使用正则表达式查询的 zend 框架
- javascript - 如何使 vue 应用程序摇树以获得更小的文件?