Hibernate Java批量操作死锁

发布于 2024-11-26 04:20:02 字数 651 浏览 2 评论 0原文

我们有使用 Hibernate 和 struts 构建的 J2EE 应用程序。我们有基于 RMI 注册表的业务功能实现。

在我们的应用程序中,大约 250 个并发用户将上传包含名为 BATCHDET 的大量数据的批次。这些批次首先根据 30 次验证进行验证,然后将它们插入到具有父子关系的表中。类似的还有其他需要大量处理的操作。例如打印等。

有一个包含 1000 万条记录的表,所有类型的事务都会访问该表,并且每个进程都会插入和更新该表。该表已成为瓶颈。我们还添加了所有必需的索引。

运行 30 分钟后,系统 JVM 将使用所有分配的 6GB RAM,并进入无响应状态。当我们试图找出根本原因时,我们意识到数据库站点存在锁定,并且与 BATCHDET 表相关的所有更新查询都处于等待状态。我们尽了一切努力,但没有运气。

当尝试使用 50 个并发用户时,系统运行顺利,但当使用 250 个用户时,系统就会崩溃(这是预期的)。 BATCHDET 几乎对​​每个模块都有很大的依赖性,没有心情重写实现,您能否提供对其的快速修复。

我们在 Hibernate 中使用 HIbernateUtil.java 实现了基于线程的事务划分。事务隔离是已提交读。有什么方法可以为所有搜索操作定义无锁。我们有 Oracle 10G RDBMS。

如果您需要任何其他详细信息,请告诉我。

〜阿马尔

We have J2EE application built using Hibernate and struts. We have RMI registry based implementation for business functionality.

In our application around 250 concurrent users are going to upload batches containing huge data named BATCHDET. These batches are first validated against 30 validation and then they are inserted to tables where we have parent and child relationship. Similar there are other operation which need huge processing. like printing etc.

There is one table containing 10 million record which gets accessed for all types of transactions and every process inserts and updates this table. This table has emerged as bottleneck. We have added all the required indexes as well.

After 30 minutes of run system JVM utilizes all the allocated 6GB of RAM and goes in no response state. When we tried to find out root cause we realized there was lock at database site and all the update queries related to BATCHDET table were in wait state. We tried everything which we could but no luck.

System run smooth when tried with 50 concurrent user but dies with 250 users which are expected. BATCHDET has lot of dependency on almost every module, not in mood to rewrite the implementation, could you please provide quick fix to it.

we have Thread based transaction demarcation at Hibernate implemented with HIbernateUtil.java. Transaction isolation is ReadCommitted. Is there any way where we can define no lock for all search operation. we have oracle 10G RDBMS.

Let me know if you need any other details.

~Amar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守护在此方 2024-12-03 04:20:02

“有什么方法可以为所有搜索操作定义无锁。我们有 Oracle 10G RDBMS。”

Oracle 不会锁定选择,因此实际上这已经就位。

Oracle 还在行级别进行锁定,因此您需要停止将表视为一个整体,而开始考虑各个行。

您需要与您的 DBA 交谈。 Oracle 中的系统和会话级别都有大量内容需要监控。 DBA 将能够查看 v$session 并告诉您各个会话正在等待什么。可能存在锁,可能是磁盘瓶颈,可能是索引争用,也可能是数据库闲置而所有低效率都在 java 层。

" Is there any way where we can define no lock for all search operation. we have oracle 10G RDBMS."

Oracle doesn't lock on selects, so in effect this is already in place.

Oracle also locks at a row level, so you need to stop thinking about the table as a whole and start thinking individual rows.

You need to talk with your DBA. There's a whole bunch of stuff to monitor in Oracle at both the system and session level. The DBA will be able to be able to look at v$session and tell you what the individual sessions are waiting on. There might be locks, it might be a disk bottle neck, it may be index contention, or it may be the database is sat there idle and all the inefficiency is in the java layer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文