zoukankan      html  css  js  c++  java
  • Failure obtaining db row lock: Lock wait timeout exceeded; try restarting transaction java定时任务

    java定时任务报错: ,localhost-startStop-1,quartz.LocalDataSourceJobStore:3876,ERROR,ClusterManager: Error managing cluster: Failure obtaining db row lock: Lock wait timeout exceeded; try restarting transaction org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Lock wait timeout exceeded; try restarting transaction [See nested exception: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction]

     Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
      NOT STARTED.
      Currently in standby mode.
      Number of jobs executed: 0
      Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
      Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is clustered.
    
    2020-03-04 17:20:00,419,localhost-startStop-1,impl.StdSchedulerFactory:1327,INFO,Quartz scheduler 'permissionEngineScheduler-dev-v_lsslli' initialized from an externally provided properties instance.
    2020-03-04 17:20:00,419,localhost-startStop-1,impl.StdSchedulerFactory:1331,INFO,Quartz scheduler version: 2.2.2
    2020-03-04 17:20:00,421,localhost-startStop-1,core.QuartzScheduler:2311,INFO,JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@416275ca
    2020-03-04 17:20:00,891,localhost-startStop-1,support.DefaultLifecycleProcessor:345,INFO,Starting beans in phase 2147483647
    2020-03-04 17:20:00,892,localhost-startStop-1,quartz.SchedulerFactoryBean:671,INFO,Starting Quartz Scheduler now
    2020-03-04 17:27:23,023,localhost-startStop-1,quartz.LocalDataSourceJobStore:3876,ERROR,ClusterManager: Error managing cluster: Failure obtaining db row lock: Lock wait timeout exceeded; try restarting transaction
    org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Lock wait timeout exceeded; try restarting transaction [See nested exception: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction]
    	at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:157)
    	at org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:113)
    	at org.quartz.impl.jdbcjobstore.JobStoreSupport.doCheckin(JobStoreSupport.java:3278)
    	at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3870)
    	at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.initialize(JobStoreSupport.java:3855)
    	at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:687)
    	at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:567)
    	at org.quartz.impl.StdScheduler.start(StdScheduler.java:142)
    	at org.springframework.scheduling.quartz.SchedulerFactoryBean.startScheduler(SchedulerFactoryBean.java:672)
    	at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:742)
    	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
    	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50)
    	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:350)
    	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
    	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112)
    	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:880)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    	at com.tenpay.fsmart.mvc.listener.SystemContextLoaderListener.contextInitialized(SystemContextLoaderListener.java:47)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
    	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    	at java.util.concurrent.FutureTask.run(FutureTask.java)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
    	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
    	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
    	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
    	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
    	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2313)
    	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2714)
    	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeQuery(FilterEventAdapter.java:465)
    	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2711)
    	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeQuery(PreparedStatementProxyImpl.java:145)
    	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:227)
    	at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:96)
    	... 30 more
    2020-03-04 17:27:23,025,localhost-startStop-1,core.QuartzScheduler:575,INFO,Scheduler permissionEngineScheduler-dev-v_lsslli_$_v_lsslli-PC21583313600379 started.
    2020-03-04 17:27:23,030,localhost-startStop-1,context.ContextLoader:344,INFO,Root WebApplicationContext: initialization completed in 450453 ms
    2020-03-04 17:27:23,040,localhost-startStop-1,extension.ExtensionLoader:59,INFO,Extension new instance:interface com.tenpay.fsmart.mvc.matcher.IPathMatcher=com.tenpay.fsmart.mvc.matcher.impl.DefaultPathMatherImpl@7c61ead0
    2020-03-04 17:27:23,055,localhost-startStop-1,extension.ExtensionLoader:59,INFO,Extension new instance:interface com.tenpay.fsmart.mvc.matcher.IPathMatcher=com.tenpay.fsmart.mvc.matcher.impl.DefaultPathMatherImpl@1ee7a13e
    2020-03-04 17:27:23,059,localhost-startStop-1,extension.ExtensionLoader:59,INFO,Extension new instance:interface com.tenpay.fsmart.mvc.matcher.IPathMatcher=com.tencent.fit.permission.permission.PermissionPathMatherImpl@6ce97a1b
    2020-03-04 17:27:23,064,localhost-startStop-1,extension.ExtensionLoader:59,INFO,Extension new instance:interface com.tenpay.fsmart.mvc.filter.support.IPermissionDenyService=com.tenpay.fsmart.mvc.filter.support.impl.DefaultPermissionDenyServiceImpl@1674b2b4
    三月 04, 2020 5:27:23 下午 org.apache.catalina.core.ApplicationContext log
    信息: Initializing Spring FrameworkServlet 'dispatch-servlet'
    

    解决
    在定时任务的文件配置中添加

    org.quartz.jobStore.lockHandler.class=org.quartz.impl.jdbcjobstore.StdRowLockSemaphore
    org.quartz.jobStore.lockHandler.maxRetry=7
    org.quartz.jobStore.lockHandler.retryPeriod=3000
    

    参考:https://github.com/quartz-scheduler/quartz/issues/268

  • 相关阅读:
    Linux 文件的软连接和硬连接
    URLOS发布NFS文件加速功能,可有效提升NFS小文件读取性能
    Vue底层学习3——手撸发布订阅模式
    Vue底层学习2——手撸数据响应化
    Vue底层学习1——原理解析
    rest api测试工具frisbyjs
    git ignore 微软临时文件(~$xxx.xlsx)
    数据虚拟化-基础概念
    elasticsearch移除映射类型(mapping type)
    activemq Virtual Destinations 虚拟目的地
  • 原文地址:https://www.cnblogs.com/szls-666/p/12494151.html
Copyright © 2011-2022 走看看