[Bug] Broken MyBatis mapper statements in jobhistory, manager-persistence and et-monitor
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Read the three mapper interfaces alongside mapper/postgresql/JobHistoryMapper.xml, mapper/mysql/JobHistoryMapper.xml, the manager-persistence ResourceManagerMapper XML, and the et-monitor JobHistoryMapper XML. Compare each statement with its Java method parameters and return type; the issue identifies the mismatches and expected behavior. Validate the mapper calls and confirm the PostgreSQL and MySQL refresh paths and the two update/delete operations work as described; pull request #5498 is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Search before asking
- I searched the issues and found no similar issues.
Linkis Component
linkis-public-enhancements, linkis-computation-governance, linkis-extensions
Steps to reproduce
Three mapper XML statements no longer match their Java mapper methods, and the PostgreSQL job history mapper is missing one statement. MyBatis resolves #{...} parameters only when a statement runs, so nothing fails at startup; the calls fail instead.
1. jobhistory: undone-task ID refresh (DefaultQueryCacheManager.refreshUndoneTask)
refreshUndoneTask() runs once at startup (init()) and every day at 00:15 (ScheduledRefreshUndoneJob). It calls JobHistoryMapper.searchWithIdOrderAsc(startDate, endDate, startId, status) and, if that throws or returns nothing, JobHistoryMapper.maxID(startDate, endDate, startId).
On PostgreSQL:
- Use PostgreSQL as the Linkis database, i.e.
wds.linkis.server.mybatis.mapperLocations=classpath*:mapper/common/*.xml,classpath*:mapper/postgresql/*.xmlas noted inlinkis.properties. - Start the public service (or wait for the 00:15 job).
searchWithIdOrderAscinmapper/postgresql/JobHistoryMapper.xmlstill filters on the oldid,umUserandengineTypeparameters and maps whole rows, while the method now takesstartDate, endDate, startId, statusand returnsList<Integer>:BindingException: Parameter 'id' not found. Available parameters are [endDate, startId, param3, param4, startDate, param1, param2, status]- The fallback
maxIDis not defined in the PostgreSQL mapper at all:BindingException: Invalid bound statement (not found): org.apache.linkis.jobhistory.dao.JobHistoryMapper.maxID
b039c2a4 (Oct 2023) changed the method parameters and the MySQL statement, and #5225 (fa008fb2) changed the return type to List<Integer> and added maxID. The PostgreSQL mapper was updated in neither commit, so on PostgreSQL refreshUndoneTask() fails on every run.
On MySQL, maxID in mapper/mysql/JobHistoryMapper.xml is SELECT id ... ORDER BY created_time, which returns one row per job in the window, while the method returns a single Integer. When no job is unfinished and two or more jobs were created in the last 24 hours, the fallback fails with:
TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 4
When the refresh fails, undoneTaskMinId does not move (on PostgreSQL it stays at wds.linkis.jobhistory.undone.job.minimum.id, default 0). /jobhistory/listundonetasks and /jobhistory/listundone then keep querying from that id instead of from the oldest unfinished job, and the exception is logged at startup and by the daily job.
2. manager-persistence: ResourceManagerMapper.deleteResourceByTicketId
The method has only @Param("ticketId"), but its <delete> contains a copied select * ... where resourceType = #{resourceType} and id in (... #{instance}):
BindingException: Parameter 'resourceType' not found. Available parameters are [ticketId, param1]
The existing ResourceManagerMapperTest#deleteResourceByTicketId fails with exactly this error. It has gone unnoticed because the module's pom.xml sets <skip>true</skip> for surefire.
#3618 (67b314bc) moved the SQL annotations into XML but kept @Delete("delete from linkis_cg_manager_linkis_resources where ticketId = #{ticketId}") on this method. #3901 (fedec809) then removed the annotation, which left the broken XML as the only definition. The only caller, DefaultResourceManagerPersistence.deleteExpiredTicketIdResource, is not used at the moment.
3. et-monitor: JobHistoryMapper.updateIncompleteJobStatusGivenIDList
The method is declared as (@Param("idList") List<Long> idList, @Param("targetStatus") String targetStatus), but the XML iterates <foreach collection="list">. MyBatis provides the implicit list key only for a single unannotated collection argument:
BindingException: Parameter 'list' not found. Available parameters are [idList, targetStatus, param1, param2]
This has been there since the mapper was added (65bcd36f). The method has no callers yet.
Expected behavior
- On PostgreSQL,
searchWithIdOrderAscusesstartDate,endDate,startIdandstatusand returns the ids of unfinished jobs in ascending order, like the MySQL statement. maxIDexists for PostgreSQL and returns the largest job id in the window on both databases.refreshUndoneTask()movesundoneTaskMinIdforward on MySQL and on PostgreSQL.deleteResourceByTicketId(ticketId)deletes the resources of that ticket and nothing else.updateIncompleteJobStatusGivenIDList(idList, targetStatus)updates the given jobs.
Your environment
- Linkis version used: master @ bad400a7 (1.9.0)
- Environment name and version:
- jdk 1.8.0 (Temurin), Maven 3.9
- MyBatis 3.5.16, MyBatis-Plus 3.5.7 (as resolved by the build)
- PostgreSQL 16.15
- H2 2.2.220 in MySQL and PostgreSQL mode (unit tests)
Anything else
- I found these by cross-checking the mapper XML statements against their mapper interfaces. Two more methods have no statement at all:
LabelManagerMapper.batchDeleteResourceByLabelIdInDirect, called fromDefaultResourceLabelPersistence.removeResourceByLabels(its service method has no callers), andJobDetailMapper.queryJobHistoryDetail, called fromJobHistoryDetailQueryServiceImpl(not registered as a bean). Both would fail withInvalid bound statement (not found)if called. The history doesn't show what SQL was intended, so I left them alone. I'm happy to remove them or add statements if someone can confirm what they should do. - Building master currently needs the
linkis-modulecompile fix from #5483.
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
- Ngôn ngữ chính
- Java
- Star
- 3.4k
- Fork
- 1.2k
- Merge trung bình
- 23 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/linkis
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug dependencies
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] linkis-application-manager's RMUtils class has a logic bugCó thể làm lại được @zhang-arvin đã nhận 88 ngày trước và không có pull request nào đang mở. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
apache/linkis#4974 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug][CI] GitHub Actions startup failure: third-party actions not in ASF allow-listCó thể đã có người làm @aiceflower đã nhận 50 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Scala Compilation is broken on master branch and recent PRsCó thể đã có người làm @pjfanning đã nhận 66 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
apache/linkis#5482 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/linkis
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bloxbean/yaci-store#1445 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
图片灯箱过长的话底部carousel滑动没有惯性Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
Spare PermissionĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Etar-Group/Etar-Calendar#2234 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] MCP resources-as-tools drops invocation context when listing templatesCó thể đã có người làm @CryoThrust đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
langchain4j/langchain4j#7320 ·
Maintainer thường phản hồi trong vòng 1 ngày