bugfix : check if table meta cache should be refreshed in AT mode
- [ ] I have registered the PR changes.
Ⅰ. Describe what this PR did
AT模式下,在构造record的时候会遍历resultset并从tablemeta里获取表结构。如果数据库表中新建了一个字段,就会报空指针。 fix思路是先把原本的buildRecords改为private方法,并在检测到null时抛出一个固定的异常,新方法在捕捉到异常后会进行tablemeta刷新(靠StatementProxy提供connection、dbtype、resourceid) 现在用双锁来控制并发,内存标识在tableMeta里面(保证同key只会刷新一次,不管是不是并发)
AbstractUndoExecutor里没有StatementProxy,但undo过程如果meta都不对应的话肯定是回滚不了,已忽略 目前刷新TableMetaCacheFactory缓存问题不大,但各个类都自己又搞了变量来缓存tablemeta,已经把这种变量去掉,改成直接从cachefactory取,性能可能有轻微下降,有其他好建议可以告诉我
Ⅱ. Does this pull request fix one issue?
fixes https://github.com/seata/seata/issues/4572
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
Codecov Report
Merging #4734 (16ca49a) into develop (00ca98c) will decrease coverage by
0.07%. The diff coverage is56.89%.
:exclamation: Current head 16ca49a differs from pull request most recent head 96bae53. Consider uploading reports for the commit 96bae53 to get more accurate results
:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more
@@ Coverage Diff @@
## develop #4734 +/- ##
=============================================
- Coverage 48.63% 48.57% -0.07%
+ Complexity 4184 4180 -4
=============================================
Files 743 744 +1
Lines 26646 26688 +42
Branches 3328 3332 +4
=============================================
+ Hits 12960 12963 +3
- Misses 12296 12326 +30
- Partials 1390 1399 +9
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...datasource/exec/mysql/MySQLUpdateJoinExecutor.java | 78.34% <ø> (ø) |
|
| ...n/java/io/seata/rm/datasource/DataSourceProxy.java | 76.59% <33.33%> (-3.80%) |
:arrow_down: |
| ...ta/rm/datasource/exec/AbstractDMLBaseExecutor.java | 51.85% <50.00%> (-5.30%) |
:arrow_down: |
| ...m/datasource/sql/struct/TableMetaCacheFactory.java | 52.63% <50.00%> (-22.37%) |
:arrow_down: |
| ...ta/rm/datasource/exception/TableMetaException.java | 66.66% <80.00%> (ø) |
|
| ...o/seata/rm/datasource/sql/struct/TableRecords.java | 68.46% <100.00%> (+1.48%) |
:arrow_up: |
| ...n/src/main/java/io/seata/common/util/IdWorker.java | 77.08% <0.00%> (-6.25%) |
:arrow_down: |
| ...ource/sql/struct/cache/AbstractTableMetaCache.java | 82.35% <0.00%> (-2.95%) |
:arrow_down: |
| ...rage/redis/store/RedisTransactionStoreManager.java | 74.93% <0.00%> (-1.57%) |
:arrow_down: |
| ...torage/file/store/FileTransactionStoreManager.java | 55.62% <0.00%> (-0.65%) |
:arrow_down: |
| ... and 1 more |
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
此pr解决add字段的问题,但是衍生额外问题是删除字段后,可能在beforesql发出后直接抛出列不存在的异常,该pr暂不解决此问题,后续考虑通过内部对列不存在+cachetablemeta不存在相应列时,刷新后从BaseTransactionalExecutor#execute开始走一遍doexecute,重试