Skip to content

[Bug] ApplicationBackUpCleanTask Runtime Error #4253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@ public class ApplicationBackUpCleanTask {
public void backUpClean() {
log.info("Start to clean application backup");
// select all application backup which count > maxBackupNum group by app_id
backUpService.lambdaQuery().groupBy(FlinkApplicationBackup::getAppId)
.having("count(*) > " + maxBackupNum).list().stream()
backUpService.lambdaQuery()
.select(FlinkApplicationBackup::getAppId)
.groupBy(FlinkApplicationBackup::getAppId)
.having("count(*) > " + maxBackupNum)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.having("count(*) > " + maxBackupNum)
.having("COUNT(*) > {0}", maxBackupNum)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gianzie Use params to pass value will be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right, this way of writing can prevent SQL injection, I have made the changes, thx!

.list()
.stream()
.map(FlinkApplicationBackup::getAppId)
.forEach(
appId -> {
// order by create_time desc and skip first maxBackupNum records and delete
// others
backUpService.lambdaQuery().eq(FlinkApplicationBackup::getAppId, appId)
.orderByDesc(FlinkApplicationBackup::getCreateTime).list()
backUpService.lambdaQuery()
.eq(FlinkApplicationBackup::getAppId, appId)
.orderByDesc(FlinkApplicationBackup::getCreateTime)
.list()
.stream()
.skip(maxBackupNum)
.forEach(
Expand Down
Loading