Xb2555 opened a new issue, #7612: URL: https://github.com/apache/incubator-seata/issues/7612
### Check Ahead - [x] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate. - [ ] I am willing to try to fix this bug myself. ### Ⅰ. Issue Description 在使用全局锁查询功能,并传入时间戳(timestamp)作为查询条件时,生成的 SQL 语句存在逻辑错误,导致无法查询到已有的数据。 生成的错误 SQL 示例: ``` select xid, transaction_id, branch_id, resource_id, table_name, pk, row_key, gmt_create, gmt_modified, status from lock_table where FLOOR(gmt_create/1000) >= 1755705600 and FLOOR(gmt_create/1000) <= 1755791999 order by gmt_create desc limit 100 offset 0; ``` ### Ⅱ. Describe what happened - 在 seata-server模块,负责构建全局锁查询的代码错误地将 gmt_create字段(MySQL datetime类型)当作一个数值(Unix Timestamp * 1000)进行处理。 - gmt_create在mysql中是 datetime类型(如 '2025-08-21 00:00:00'),而非存储毫秒时间戳的 bigint类型。 - 在 SQL 中使用 FLOOR(gmt_create/1000)会导致 MySQL 对 datetime值进行隐式转换和数学运算,结果完全错误(例如 '2025-08-21 00:00:00' / 1000 = 2025.000000),导致查询条件永远不满足。 ### Ⅲ. Describe what you expected to happen 应当返回所有在 2025-08-21 00:00:00至 2025-08-21 23:59:59期间创建的锁记录。 ### Ⅳ. How to reproduce it (as minimally and precisely as possible) 1.确保 lock_table中存在 gmt_create字段值为 2025-08-21附近的数据。 2.通过 Seata 的全局锁查询接口(或直接调用相关 Service方法),传入一个查询条件: - startTime: 1755705600000 (表示 2025-08-21 00:00:00 UTC+8) - endTime: 1755791999000 (表示 2025-08-21 23:59:59 UTC+8) 3.观察查询结果,本该匹配的数据没有被返回。 ### Ⅴ. Anything else we need to know? 主要错误发生在以下代码中: <img width="1322" height="1122" alt="Image" src="https://github.com/user-attachments/assets/5ff603bc-3493-4162-bad2-00ec12e547be" /> ### Ⅵ. Environment - JDK Version: 1.8 - Seata Server Version: 2.6.0-SNAPSHOT - Database version: mysql8.3 - OS: Windows -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
