Omaha #4279 Force purge of satellite_spatial to always keep newest gids.

Former-commit-id: 99700a1f6c2c491a95cb45d9abf70322d54c26bc
This commit is contained in:
Roger Ferrel 2015-09-17 13:34:58 -05:00
parent 3509e3603d
commit 132e7ef9a5

View file

@ -69,6 +69,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
* Apr 15, 2014 4388 bsteffen Preserve fill value across interpolation levels. * Apr 15, 2014 4388 bsteffen Preserve fill value across interpolation levels.
* Jul 07, 2015 4279 rferrel Override delete to clean up orphan entries in satellite_spatial table. * Jul 07, 2015 4279 rferrel Override delete to clean up orphan entries in satellite_spatial table.
* Aug 11, 2015 4673 rjpeter Remove use of executeNativeSql. * Aug 11, 2015 4673 rjpeter Remove use of executeNativeSql.
* Sep 17, 2015 4279 rferrel Do not purge the newest satellite_spatial entries.
* </pre> * </pre>
* *
* @author bphillip * @author bphillip
@ -427,7 +428,14 @@ public class SatelliteDao extends PluginDao {
* Delete orphan entries in the satellite_spatial table. * Delete orphan entries in the satellite_spatial table.
*/ */
try { try {
this.executeSQLUpdate("delete from satellite_spatial where gid not in (select distinct coverage_gid from satellite) ;"); /*
* Keep the newest satellite_spatial entries. May be part of a
* record not fully committed.
*/
String sqlCmd = "DELETE FROM satellite_spatial WHERE"
+ "gid NOT IN (SELECT DISTINCT coverage_gid FROM satellite)"
+ "AND gid < (SELECT max(gid)-25 FROM satellite_spatial) ;";
this.executeSQLUpdate(sqlCmd);
} catch (Exception e) { } catch (Exception e) {
logger.error("Error purging orphaned satellite_spatial entries", e); logger.error("Error purging orphaned satellite_spatial entries", e);
} }