apache / hertzbeat

Apache HertzBeat(incubating) is a real-time monitoring system with agentless, performance cluster, prometheus-compatible, custom monitoring and status page building capabilities.
https://hertzbeat.apache.org/
Apache License 2.0
5.46k stars 947 forks source link

[bugfix] fix delete limit error #2413

Closed Aias00 closed 1 month ago

Aias00 commented 1 month ago

What's changed?

fix delete limit error

2024-07-30 14:57:01 [jpa-metrics-cleaner-0] ERROR org.apache.hertzbeat.warehouse.store.history.jpa.JpaDatabaseDataStorage - expiredDataCleaner database error: Exception [EclipseLink-4002] (Eclipse Persistence Services - 4.0.2.v202306161219): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':delNum' at line 1 Error Code: 1064 Call: delete from hzb_history limit :delNum Query: DataModifyQuery(sql="delete from hzb_history limit :delNum").

Checklist

Add or update API

pwallk commented 1 month ago

Similar pr #2329

tomsun28 commented 1 month ago

hi @Aias00 , how about this similar pr https://github.com/apache/hertzbeat/pull/2329 @pwallk describe

the delNum argument cannot be passed correctly and should be changed instead:delete from hzb_history limit ?1,secondly postgresql does not support delete followed by limit,Therefore, it should be deleted with nested subqueries (earlier MySQL versions did not support nested subqueries, such as 5.7, 5.6, so two layers of nesting are used).

Aias00 commented 1 month ago

hi @Aias00 , how about this similar pr #2329 @pwallk describe

the delNum argument cannot be passed correctly and should be changed instead:delete from hzb_history limit ?1,secondly postgresql does not support delete followed by limit,Therefore, it should be deleted with nested subqueries (earlier MySQL versions did not support nested subqueries, such as 5.7, 5.6, so two layers of nesting are used).

yes, i made a mistake, postgresql truly not support this delete limit statement. @pwallk was right, i will close this pr 😂