Skip to content

Commit 980349d

Browse files
committed
修复当业务模块设置readOnly是会出现锁表问题
1 parent 73bf363 commit 980349d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tx-plugins-db/src/main/java/com/codingapi/tx/datasource/relational/LCNDBConnection.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public class LCNDBConnection extends AbstractTransactionThread implements LCNCon
4343

4444
private TxTask waitTask;
4545

46+
private boolean readOnly = false;
47+
4648

4749
public LCNDBConnection(Connection connection, DataSourceService dataSourceService, ICallClose<ILCNResource> runnable) {
4850
logger.info("init lcn connection ! ");
@@ -102,6 +104,11 @@ public void close() throws SQLException {
102104
return;
103105
}
104106

107+
if(readOnly){
108+
closeConnection();
109+
logger.info("now transaction is readOnly , groupId:" + groupId);
110+
return;
111+
}
105112

106113
logger.info("now transaction state is " + state + ", (1:commit,0:rollback) groupId:" + groupId);
107114

@@ -187,6 +194,7 @@ public void setAutoCommit(boolean autoCommit) throws SQLException {
187194
public void setReadOnly(boolean readOnly) throws SQLException {
188195

189196
if(readOnly) {
197+
this.readOnly = readOnly;
190198
logger.info("setReadOnly - >" + readOnly);
191199
connection.setReadOnly(readOnly);
192200

0 commit comments

Comments
 (0)