| Line 40... |
Line 40... |
| 40 |
private static final String HIKARI_MAX_POOL_SIZE = "hikari.maximumPoolSize";
|
40 |
private static final String HIKARI_MAX_POOL_SIZE = "hikari.maximumPoolSize";
|
| 41 |
private static final String HIKARI_MIN_IDLE = "hikari.minimumIdle";
|
41 |
private static final String HIKARI_MIN_IDLE = "hikari.minimumIdle";
|
| 42 |
private static final String HIKARI_IDLE_TIMEOUT = "hikari.idleTimeout";
|
42 |
private static final String HIKARI_IDLE_TIMEOUT = "hikari.idleTimeout";
|
| 43 |
private static final String HIKARI_MAX_LIFETIME = "hikari.maxLifetime";
|
43 |
private static final String HIKARI_MAX_LIFETIME = "hikari.maxLifetime";
|
| 44 |
private static final String HIKARI_CONNECTION_TIMEOUT = "hikari.connectionTimeout";
|
44 |
private static final String HIKARI_CONNECTION_TIMEOUT = "hikari.connectionTimeout";
|
| - |
|
45 |
// InnoDB lock wait timeout (seconds) applied per-connection. Lowered from the MySQL
|
| - |
|
46 |
// default of 50s so a transaction blocked on a row lock (e.g. the userwallet FOR UPDATE)
|
| - |
|
47 |
// fails fast and frees its Tomcat thread + pool connection instead of parking, which
|
| - |
|
48 |
// during burst windows otherwise starves the HikariCP pool. Paired with retry-on-lock
|
| - |
|
49 |
// at the service layer. Override per environment via property; default 10s.
|
| - |
|
50 |
private static final String MYSQL_LOCK_WAIT_TIMEOUT = "mysql.innodb.lock.wait.timeout";
|
| 45 |
|
51 |
|
| 46 |
private Resource resource = AppConfig.getResource();
|
52 |
private Resource resource = AppConfig.getResource();
|
| 47 |
|
53 |
|
| 48 |
private Properties loadAllProperties() {
|
54 |
private Properties loadAllProperties() {
|
| 49 |
Properties properties = new Properties();
|
55 |
Properties properties = new Properties();
|
| Line 72... |
Line 78... |
| 72 |
config.setMinimumIdle(Integer.parseInt(properties.getProperty(HIKARI_MIN_IDLE, "2")));
|
78 |
config.setMinimumIdle(Integer.parseInt(properties.getProperty(HIKARI_MIN_IDLE, "2")));
|
| 73 |
config.setIdleTimeout(Long.parseLong(properties.getProperty(HIKARI_IDLE_TIMEOUT, "30000")));
|
79 |
config.setIdleTimeout(Long.parseLong(properties.getProperty(HIKARI_IDLE_TIMEOUT, "30000")));
|
| 74 |
config.setMaxLifetime(Long.parseLong(properties.getProperty(HIKARI_MAX_LIFETIME, "1800000")));
|
80 |
config.setMaxLifetime(Long.parseLong(properties.getProperty(HIKARI_MAX_LIFETIME, "1800000")));
|
| 75 |
config.setConnectionTimeout(Long.parseLong(properties.getProperty(HIKARI_CONNECTION_TIMEOUT, "30000")));
|
81 |
config.setConnectionTimeout(Long.parseLong(properties.getProperty(HIKARI_CONNECTION_TIMEOUT, "30000")));
|
| 76 |
config.setLeakDetectionThreshold(30000);
|
82 |
config.setLeakDetectionThreshold(30000);
|
| - |
|
83 |
config.setConnectionInitSql("SET SESSION innodb_lock_wait_timeout = "
|
| - |
|
84 |
+ Integer.parseInt(properties.getProperty(MYSQL_LOCK_WAIT_TIMEOUT, "10")));
|
| 77 |
|
85 |
|
| 78 |
return new HikariDataSource(config);
|
86 |
return new HikariDataSource(config);
|
| 79 |
}
|
87 |
}
|
| 80 |
|
88 |
|
| 81 |
@Bean
|
89 |
@Bean
|