我正在使用spring批量数据加载器。我有15000个文件,只使用多源分区器处理一个文件。似乎在尝试将数据插入表时发生了表锁。这里没有定义并行步骤。文件处理速度很慢。以下是块项读取器和写入器的代码片段以及表锁的sql输出。
Spring配置文件
<step id="filestep" xmlns="http://www.springframework.org/schema/batch" >
<tasklet allow-start-if-complete="true" transaction-manager="ratransactionManager" >
<chunk writer="jdbcItenWriter" reader="fileItemReader" processor="itemProcessor" commit-interval="500" retry-limit="2">
<retryable-exception-classes>
<include class="org.springframework.dao.DeadlockLoserDataAccessException"/>
</retryable-exception-classes>
</chunk>
<listeners>
<listener ref="customStepExecutionListener">
</listener>
</listeners>
</tasklet>
<end on ="FAILED"/>
</step>
Oracle锁定
select
object_name,
object_type,
session_id,
type, -- Type or system/user lock
lmode, -- lock mode in which session holds lock
request,
block,
ctime,
owner,
id1,id2 -- Time since current mode was granted
from
v$locked_object, all_objects, v$lock
where
v$locked_object.object_id = all_objects.object_id AND
v$lock.id1 = all_objects.object_id AND
v$lock.sid = v$locked_object.session_id
and all_objects.OBJECT_NAME like '%MSC%'
order by
session_id, ctime desc, object_name
OBJECT_NAME OBJECT_TYPE SESSION_ID TYPE LMODE REQUEST BLOCK CTIME OWNER ID1 ID2
STAGING_TABLE_MSC TABLE 137 TM 3 0 0 39 CDRR 9289370 0
答案 0 :(得分:2)
LMODE 3只是一个行锁定,可能来自普通插入,应该不是问题。
如果您看过LMODE 6,则意味着整个表格都被锁定。例如,来自INSERT /*+APPEND*/
的直接路径写入。
请参阅V$LOCK文档。