Skip to content
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

Replace TRUNCATE with CLEAR TABLE #507

Open
mhidas opened this issue Mar 21, 2017 · 11 comments
Open

Replace TRUNCATE with CLEAR TABLE #507

mhidas opened this issue Mar 21, 2017 · 11 comments
Assignees

Comments

@mhidas
Copy link
Contributor

mhidas commented Mar 21, 2017

When a harvester needs to delete all rows from a table before writing new data to it, the "clear table" option should be used instead of "truncate table". Truncate requires an exclusive lock on the table and prevents any subsequent queries from running, even while the truncate itself is still waiting to run.

This may have been part of the cause for a recent geoserver-123 outage (https://github.com/aodn/issues/issues/29)

@mhidas
Copy link
Contributor Author

mhidas commented Mar 21, 2017

Harvesters affected include SOOP_AUSCPR and ANMN_NRS_BGC. Any others?

@lbesnard @bpasquer @xhoenner

@lbesnard
Copy link
Contributor

Im sure there are many more. It's quite bizarre the outage happened after having written these harvesters years ago

@xhoenner
Copy link
Contributor

I'd say most harvesters use truncate since it was what we've been told to use in the original Talend Google document. Surely we could do a batch update, that's what I ended up doing for AATAMS_ACOUSTIC_REPORTING.

@jonescc
Copy link
Contributor

jonescc commented Mar 23, 2017

The issue in production the other day was mainly caused by a jndi connection pool leak in geoserver performing shapefile downloads. The truncate just exacerbated the problem (blocked access to that table from any other application).

I've attached a list of harvesters which still use the TRUNCATE table action and in sql below. We've actually been moving to modifying data based on what files have changed rather than wholesale truncate and repopulate so there aren't as many as you would think.

./ANMN_MHLWAVE/process/subjobs/HarvestMHLwaveMetadata_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./SRS_OC_SOOP_RAD/process/SRS_OC_SOOP_RAD/subjobs/harvest_soop_rad_metadata_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AUV_VIEWER_TRACKS/process/AUV_VIEWER_TRACK/subjobs/auv_reporting_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/station_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/plankton_zooplankton_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/plankton_zooplankton_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/tss_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/chemistry_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/plankton_biomass_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/qc_flags_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/phypig_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/picoplankton_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/plankton_phytoplankton_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANMN_NRS_BGC/process/ANMN_NRS_BGC/subjobs/plankton_phytoplankton_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANFOG_RT/process/ANFOG_RT/subjobs_RT/Harvest_RT_Listing_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_uor_obs_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_sur_obs_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_uor_obs_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_sur_obs_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_mbt_obs_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_ctd_obs_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_xbt_obs_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_xbt_obs_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_ctd_obs_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjob_obs/Harvest_mbt_obs_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_uor_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_apb_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_ctd_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_pfl_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_osd_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_sur_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_gld_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_mbt_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_xbt_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_apb_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_xbt_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_gld_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_mbt_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_uor_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_osd_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_ctd_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_pfl_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./WODB/process/subjobs/Harvest_sur_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./SOOP_BA/process/SOOP_BA/subjobs/harvest_soop_ba_metadata_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./TEST_ANFOG/process/ANFOG_RT/subjobs_RT/Harvest_RT_Listing_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./GEONETWORK/process/Transfers/HarvestHistory_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Harvest_mooring_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Harvest_hydrology_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Harvest_adcp_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Populate_map_tables_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Populate_map_tables_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Populate_map_tables_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Populate_map_tables_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Populate_map_tables_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Populate_map_tables_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Populate_map_tables_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Harvest_ctd_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Harvest_trajectory_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AODN_CSIRO_CMAR/process/aodn_csiro_cmar_subjobs/Harvest_xbt_data_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AATAMS_SATTAG_NRT/process/aatams_sattag_nrt_subjobs/Create_map_table_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AUV/process/AUV/subjobs/createWMS_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./SOOP_AUSCPR/process/SOOP_AUSCPR/subjobs/zoop_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./SOOP_AUSCPR/process/SOOP_AUSCPR/subjobs/pci_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./SOOP_AUSCPR/process/SOOP_AUSCPR/subjobs/auscp_phyto_taxon_changelog_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./SOOP_AUSCPR/process/SOOP_AUSCPR/subjobs/phyto_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./SOOP_AUSCPR/process/SOOP_AUSCPR/subjobs/auscp_zoop_taxon_changelog_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AUS_PHYTO_DB/process/AUS_PHYTO_DB/subjobs/data_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./AUS_PHYTO_DB/process/AUS_PHYTO_DB/subjobs/data_harvest_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./SRS_LJCO_AERONET_TS/process/SRS_LJCO_AERONET_TS/subjob/aeronet_lev2_process_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANFOG_DM/ANFOG_DM-master/process/ANFOG_RT/subjobs_RT/CreateWMS_RT_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANFOG_DM/ANFOG_DM-master/process/ANFOG_RT/subjobs_RT/CreateWMS_RT_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANFOG_DM/ANFOG_DM-master/process/ANFOG_dm/subjobs/createWMS_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
./ANFOG_DM/ANFOG_DM-master/process/ANFOG_dm/subjobs/createWMS_0.1.item:    <elementParameter field="CLOSED_LIST" name="TABLE_ACTION" value="TRUNCATE"/>
SRS_ALTIMETRY/process/SRS_ALTIMETRY/subjobs/harvestFile_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;&#xA;TRUNCATE TABLE temporary_sub_select_wms;&#xA;INSERT INTO temporary_sub_select_wms (&#xA;SELECT &quot; + context.file_id  + &quot; as file_id, &#xA;min(\&quot;TIME\&quot;) AS time_coverage_start, &#xA;max(\&quot;TIME\&quot;) AS time_coverage_end, &#xA;COUNT(\&quot;TEMP\&quot;) AS \&quot;TEMP\&quot;,&#xA;COUNT(\&quot;PSAL\&quot;) AS \&quot;PSAL\&quot;,&#xA;COUNT(\&quot;PRES\&quot;) AS \&quot;PRES\&quot;,&#xA;COUNT(\&quot;CNDC\&quot;) AS \&quot;CNDC\&quot;,&#xA;COUNT(\&quot;UCUR\&quot;) AS \&quot;UCUR\&quot;,&#xA;COUNT(\&quot;VCUR\&quot;) AS \&quot;VCUR\&quot;,&#xA;geom&#xA;FROM  measurements where file_id = &quot; + context.file_id + &quot;&#xA;GROUP BY geom);&quot;&#xA;"/>
AUV/process/AUV/AUV_harvester_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;DELETE FROM deployments where file_id = &quot; + ((Long)globalMap.get(&quot;iDeletedFileList_1_FILE_ID&quot;)).intValue() + &quot;;&#xA;DELETE FROM measurements_st where file_id = &quot; + ((Long)globalMap.get(&quot;iDeletedFileList_1_FILE_ID&quot;)).intValue() + &quot;;&#xA;DELETE FROM measurements_b where file_id = &quot; + ((Long)globalMap.get(&quot;iDeletedFileList_1_FILE_ID&quot;)).intValue() + &quot;;&#xA;TRUNCATE TABLE  table_master; TRUNCATE TABLE measurements_merged_data;&quot;"/>
AUV/process/AUV/subjobs/mergeMeasurements_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;TRUNCATE TABLE  table_master;&#xA;INSERT INTO table_master  (&#xA;SELECT dive_name, \&quot;TIME\&quot; , \&quot;LATITUDE\&quot;, \&quot;LONGITUDE\&quot;,\&quot;DEPTH\&quot;,geom  from measurements_b &#xA;UNION &#xA;SELECT dive_name, \&quot;TIME\&quot; , \&quot;LATITUDE\&quot;, \&quot;LONGITUDE\&quot;,\&quot;DEPTH\&quot;,geom  from measurements_st&#xA; where dive_name = '&quot; + context.dive_name + &quot;' ORDER BY \&quot;TIME\&quot;);&quot;&#xA;"/>
AUV/process/AUV/subjobs/mergeMeasurements_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;&#xA;TRUNCATE TABLE  measurements_merged_data;&#xA;INSERT INTO measurements_merged_data (&#xA;SELECT &#xA;table_master.dive_name,&#xA;table_master.\&quot;TIME\&quot;,&#xA;table_master.\&quot;LATITUDE\&quot;, &#xA;table_master.\&quot;LONGITUDE\&quot;, &#xA;table_master.\&quot;DEPTH\&quot;, &#xA;measurements_b.\&quot;CDOM\&quot;,&#xA;measurements_b.\&quot;CPHL\&quot;,&#xA;measurements_b.\&quot;OPBS\&quot;,&#xA;measurements_st.\&quot;PSAL\&quot;,&#xA;measurements_st.\&quot;TEMP\&quot;,&#xA;table_master.geom&#xA;&#xA;from table_master&#xA;&#xA;LEFT OUTER JOIN measurements_st ON (measurements_st.\&quot;LATITUDE\&quot; = table_master.\&quot;LATITUDE\&quot; )&#xA;LEFT OUTER JOIN measurements_b ON (measurements_b.\&quot;LATITUDE\&quot; = table_master.\&quot;LATITUDE\&quot; )&#xA;&#xA;ORDER BY \&quot;TIME\&quot;);&#xA;&#xA;TRUNCATE TABLE  table_master;&#xA;&quot;"/>
AUV/process/AUV/subjobs/createWMS_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;TRUNCATE TABLE  measurements_merged_data;&quot;"/>
AUV/process/AUV/subjobs/data_and_metadata_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;DELETE FROM deployments where file_id = &quot; + context.fileid + &quot;;&#xA;DELETE FROM measurements_st where file_id = &quot; + context.fileid + &quot;;&#xA;DELETE FROM measurements_b where file_id = &quot; + context.fileid + &quot;;&#xA;TRUNCATE TABLE  table_master; TRUNCATE TABLE measurements_merged_data;&quot;"/>
SOOP_TRV/process/SOOP_TRV/subjobs/oneFileProcess_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;&#xA;TRUNCATE TABLE temporary_sub_select_wms;&#xA;INSERT INTO temporary_sub_select_wms&#xA;(SELECT trip_id, &#xA;min(\&quot;TIME\&quot;) AS time_coverage_start, &#xA;max(\&quot;TIME\&quot;) AS time_coverage_end, &#xA;COUNT(\&quot;TURB\&quot;) AS \&quot;TURB\&quot;,&#xA;COUNT(\&quot;TEMP\&quot;) AS \&quot;TEMP\&quot;,&#xA;COUNT(\&quot;CPHL\&quot;) AS \&quot;CPHL\&quot;,&#xA;COUNT(\&quot;PSAL\&quot;) AS \&quot;PSAL\&quot;,&#xA;ST_SimplifyPreserveTopology(ST_MakeLine(geom ORDER BY \&quot;TIME\&quot;),0.005) AS geom&#xA;FROM  measurements_merged_data where trip_id = &quot; + context.trip_id +&quot; GROUP BY trip_id);&#xA;&quot;"/>
SOOP_TRV/process/SOOP_TRV/subjobs/oneFileProcess_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;TRUNCATE TABLE table_master;&quot;&#xA;"/>
SOOP_TRV/process/SOOP_TRV/SOOP_TRV_harvester_0.1.item:    <elementParameter field="MEMO" name="INLINE_CONTENT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>&#xA;&lt;databaseChangeLog xmlns=&quot;http://www.liquibase.org/xml/ns/dbchangelog&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd&quot;>&#xA; &#xA;    &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-1&quot;>&#xA;       &lt;sql>&#xA;       CREATE TABLE deployments&#xA;(&#xA;  deploy_id bigserial,&#xA;  file_id integer NOT NULL,&#xA;  time_coverage_start character varying(100),&#xA;  time_coverage_end character varying(100),&#xA;  platform_code character varying(100),&#xA;  file_version character varying(500),&#xA;  aims_channel_id integer,&#xA;  trip_id integer,&#xA;  metadata_uuid character varying(100),&#xA;  cdm_data_type character varying(100),&#xA;  institution character varying(100),&#xA;  data_centre_email character varying(100),&#xA;  principal_investigator_email character varying(100),&#xA;  source character varying(100),&#xA;  project character varying(100),&#xA;  geospatial_vertical_min character varying(100),&#xA;  netcdf_version character varying(100),&#xA;  local_time_zone character varying(100),&#xA;  geospatial_vertical_max character varying(100),&#xA;  data_centre character varying(100),&#xA;  naming_authority character varying(100),&#xA;  author character varying(100),&#xA;  date_created character varying(100),&#xA;  title character varying(100),&#xA;  &quot;references&quot; character varying(100),&#xA;  vessel_name character varying(100),&#xA;  principal_investigator character varying(100),&#xA;  CONSTRAINT deployments_pkey PRIMARY KEY (deploy_id ),&#xA;  CONSTRAINT fk_file_id FOREIGN KEY (file_id)&#xA;      REFERENCES indexed_file (id) MATCH SIMPLE&#xA;      ON UPDATE CASCADE ON DELETE CASCADE&#xA;)&#xA;&#xA;       &lt;/sql>&#xA;    &lt;/changeSet>&#xA;   &#xA;&#xA;    &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-2&quot;>&#xA;       &lt;sql>&#xA;       CREATE TABLE measurements_cphl&#xA;(&#xA;  file_id integer,&#xA;  measurement bigserial,&#xA;  &quot;TIME&quot; timestamp with time zone,&#xA;  &quot;LATITUDE&quot; double precision,&#xA;  &quot;LATITUDE_quality_control&quot; character(1),&#xA;  &quot;LONGITUDE&quot; double precision,&#xA;  &quot;LONGITUDE_quality_control&quot; character(1),&#xA;  geom geometry,&#xA;  &quot;CPHL&quot; real,&#xA;  &quot;CPHL_quality_control&quot; character(1),&#xA;  trip_id integer,&#xA;  CONSTRAINT measurements_cphl_pkey PRIMARY KEY (measurement ),&#xA;  CONSTRAINT fk_file_id FOREIGN KEY (file_id)&#xA;      REFERENCES indexed_file (id) MATCH SIMPLE&#xA;      ON UPDATE CASCADE ON DELETE CASCADE&#xA;&#xA;)&#xA;      &lt;/sql>&#xA;    &lt;/changeSet>&#xA;&#xA;    &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-3&quot;>&#xA;       &lt;sql>&#xA;       CREATE TABLE measurements_psal&#xA;(&#xA;  file_id integer,&#xA;  measurement bigserial,&#xA;  &quot;TIME&quot; timestamp with time zone,&#xA;  &quot;LATITUDE&quot; double precision,&#xA;  &quot;LATITUDE_quality_control&quot; character(1),&#xA;  &quot;LONGITUDE&quot; double precision,&#xA;  &quot;LONGITUDE_quality_control&quot; character(1),&#xA;  geom geometry,&#xA;  &quot;PSAL&quot; real,&#xA;  &quot;PSAL_quality_control&quot; character(1),&#xA;  trip_id  smallint,&#xA;  CONSTRAINT measurements_psal_pkey PRIMARY KEY (measurement ),&#xA;  CONSTRAINT fk_file_id FOREIGN KEY (file_id)&#xA;      REFERENCES indexed_file (id) MATCH SIMPLE&#xA;      ON UPDATE CASCADE ON DELETE CASCADE&#xA;)&#xA;       &lt;/sql>&#xA;    &lt;/changeSet>&#xA;&#xA;    &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-4&quot;>&#xA;       &lt;sql>&#xA;       CREATE TABLE measurements_temp&#xA;(&#xA;  file_id integer,&#xA;  measurement bigserial,&#xA;  &quot;TIME&quot; timestamp with time zone,&#xA;  &quot;LATITUDE&quot; double precision,&#xA;  &quot;LATITUDE_quality_control&quot; character(1),&#xA;  &quot;LONGITUDE&quot; double precision,&#xA;  &quot;LONGITUDE_quality_control&quot; character(1),&#xA;  geom geometry,&#xA;  &quot;TEMP&quot; real,&#xA;  &quot;TEMP_quality_control&quot; character(1),&#xA;  trip_id integer,&#xA;  CONSTRAINT measurements_temp_pkey PRIMARY KEY (measurement ),&#xA;  CONSTRAINT fk_file_id FOREIGN KEY (file_id)&#xA;      REFERENCES indexed_file (id) MATCH SIMPLE&#xA;      ON UPDATE CASCADE ON DELETE CASCADE&#xA;)&#xA;       &lt;/sql>&#xA;    &lt;/changeSet>&#xA;&#xA;    &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-5&quot;>&#xA;       &lt;sql>&#xA;       CREATE TABLE measurements_turb&#xA;(&#xA;  file_id integer,&#xA;  measurement bigserial,&#xA;  &quot;TIME&quot; timestamp with time zone,&#xA;  &quot;LATITUDE&quot; double precision,&#xA;  &quot;LATITUDE_quality_control&quot; character(1),&#xA;  &quot;LONGITUDE&quot; double precision,&#xA;  &quot;LONGITUDE_quality_control&quot; character(1),&#xA;  geom geometry,&#xA;  &quot;TURB&quot; real,&#xA;  &quot;TURB_quality_control&quot; character(1),&#xA;  trip_id integer,&#xA;  CONSTRAINT measurements_turb_pkey PRIMARY KEY (measurement ),&#xA;  CONSTRAINT fk_file_id FOREIGN KEY (file_id)&#xA;      REFERENCES indexed_file (id) MATCH SIMPLE&#xA;      ON UPDATE CASCADE ON DELETE CASCADE&#xA;)&#xA;       &lt;/sql>&#xA;    &lt;/changeSet>&#xA;&#xA; &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-6&quot;>&#xA;       &lt;sql>&#xA;ALTER TABLE measurements_cphl&#xA;ALTER COLUMN geom TYPE geometry(GEOMETRY, 4326)&#xA;USING ST_SetSRID(geom,4326);&#xA;CREATE INDEX measurements_cphl_gist_idx ON measurements_cphl USING GIST (geom); &#xA; &lt;/sql>&#xA;        &lt;sql>&#xA;ALTER TABLE measurements_psal&#xA;ALTER COLUMN geom TYPE geometry(GEOMETRY, 4326)&#xA;USING ST_SetSRID(geom,4326);&#xA;CREATE INDEX measurements_psal_gist_idx ON measurements_psal USING GIST (geom); &#xA;  &lt;/sql>&#xA;        &lt;sql>&#xA;ALTER TABLE measurements_temp&#xA;ALTER COLUMN geom TYPE geometry(GEOMETRY, 4326)&#xA;USING ST_SetSRID(geom,4326);&#xA;CREATE INDEX measurements_temp_gist_idx ON measurements_temp USING GIST (geom); &#xA;  &lt;/sql>&#xA;        &lt;sql>&#xA;ALTER TABLE measurements_turb&#xA;ALTER COLUMN geom TYPE geometry(GEOMETRY, 4326)&#xA;USING ST_SetSRID(geom,4326);&#xA;CREATE INDEX measurements_turb_gist_idx ON measurements_turb USING GIST (geom); &#xA;  &lt;/sql>&#xA;    &lt;/changeSet>&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-7&quot;>&#xA;       &lt;sql>&#xA;ALTER TABLE measurements_cphl ADD CHECK (ST_IsValid(geom));&#xA;ALTER TABLE measurements_psal ADD CHECK (ST_IsValid(geom));&#xA;ALTER TABLE measurements_temp ADD CHECK (ST_IsValid(geom));&#xA;ALTER TABLE measurements_turb ADD CHECK (ST_IsValid(geom));&#xA;  &lt;/sql>&#xA;&lt;/changeSet>&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-8&quot;>&#xA;       &lt;sql>&#xA;ALTER TABLE measurements_psal ALTER COLUMN trip_id TYPE integer;&#xA;  &lt;/sql>&#xA;&lt;/changeSet>&#xA;&#xA;&#xA;&#xA; &#xA;       &lt;changeSet author=&quot;talend&quot; id=&quot;createTable_measurements_merged_data&quot;>&#xA;       &lt;sql>&#xA;       CREATE TABLE measurements_merged_data&#xA;(&#xA;  trip_id integer,&#xA;  &quot;TIME&quot; timestamp with time zone,&#xA;  &quot;LATITUDE&quot; double precision,&#xA;  &quot;LONGITUDE&quot; double precision,&#xA;  geom geometry,&#xA;  &quot;TURB&quot; real,&#xA;  &quot;TEMP&quot; real,&#xA;  &quot;CPHL&quot; real,&#xA;  &quot;PSAL&quot; real&#xA;)&#xA;       &lt;/sql>&#xA;    &lt;/changeSet>&#xA;   &#xA;&#xA; &lt;changeSet author=&quot;talend&quot; id=&quot;createTableMaster&quot;>&#xA;        &lt;sql>&#xA;CREATE TABLE table_master&#xA;(&#xA;trip_id integer,&#xA;  &quot;TIME&quot; timestamp with time zone,&#xA;  &quot;LATITUDE&quot; double precision,&#xA;  &quot;LONGITUDE&quot; double precision,&#xA;  geom geometry&#xA;)&#xA;  ;&#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA; &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-9&quot;>&#xA;&#xA;        &lt;sql>&#xA;ALTER TABLE measurements_merged_data&#xA;ALTER COLUMN geom TYPE geometry(GEOMETRY, 4326)&#xA;USING ST_SetSRID(geom,4326);&#xA;  &lt;/sql>&#xA;&#xA;        &lt;sql>&#xA;ALTER TABLE table_master&#xA;ALTER COLUMN geom TYPE geometry(GEOMETRY, 4326)&#xA;USING ST_SetSRID(geom,4326);&#xA;CREATE INDEX table_master_gist_idx ON table_master USING GIST (geom); &#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA; &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-10&quot;>&#xA;        &lt;sql>&#xA;ALTER TABLE measurements_merged_data ADD CHECK (ST_IsValid(geom));&#xA;ALTER TABLE table_master ADD CHECK (ST_IsValid(geom));&#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA; &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-11&quot;>&#xA;        &lt;sql>&#xA;ALTER TABLE table_master add column measurements bigserial;&#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;1382580250154-12&quot;>&#xA;        &lt;sql>&#xA;CREATE TABLE temporary_sub_select_wms&#xA;(&#xA;  trip_id integer,&#xA;  time_start timestamp with time zone,&#xA;  time_end timestamp with time zone,&#xA;  &quot;TURB&quot; bigint,&#xA;  &quot;TEMP&quot; bigint,&#xA;  &quot;CPHL&quot; bigint,&#xA;  &quot;PSAL&quot; bigint,&#xA;  geom geometry,&#xA;  CONSTRAINT temporary_sub_select_wms_geom_check CHECK (st_isvalid(geom)))&#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA; &#xA; &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250144-1&quot;>&#xA;       &lt;sql>&#xA; CREATE TABLE vessel_names&#xA;(&#xA;  vessel_name character varying(50) NOT NULL,&#xA;  platform_code character varying(50),&#xA;  colour character varying(50),&#xA;  CONSTRAINT vessel_names_pkey PRIMARY KEY (vessel_name )&#xA;)&#xA;       &lt;/sql>&#xA;    &lt;/changeSet>&#xA;   &#xA;&#xA; &lt;changeSet author=&quot;talend&quot; id=&quot;1382580250144-2&quot;>&#xA;        &lt;sql>&#xA;CREATE TABLE visualisation_wms&#xA;(&#xA;  trip_id integer,&#xA;   metadata_uuid character varying(100),&#xA;  time_start timestamp with time zone,&#xA;  time_end timestamp with time zone,&#xA;  vessel_name character varying(50),&#xA;  colour character varying(50),&#xA;  &quot;TURB_b&quot; boolean,&#xA;  &quot;TEMP_b&quot; boolean,&#xA;  &quot;CPHL_b&quot; boolean,&#xA;  &quot;PSAL_b&quot; boolean,&#xA;  geom geometry,&#xA;  CONSTRAINT visualisation_wms_geom_check CHECK (st_isvalid(geom)))&#xA;&#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&#xA;&lt;changeSet author=&quot;bpasquer&quot; id=&quot;rename_time_variables&quot;>&#xA;    &lt;sql>&#xA;    ALTER TABLE temporary_sub_select_wms RENAME COLUMN time_start TO time_coverage_start;&#xA;    ALTER TABLE temporary_sub_select_wms RENAME COLUMN time_end TO time_coverage_end;&#xA;    ALTER TABLE visualisation_wms RENAME COLUMN time_start TO time_coverage_start;&#xA;    ALTER TABLE visualisation_wms RENAME COLUMN time_end TO time_coverage_end;&#xA;  &#xA;   &lt;/sql>&#xA;  &lt;/changeSet>&#xA;&#xA;&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;1382580250144-3&quot;>&#xA;        &lt;sql>&#xA;ALTER TABLE visualisation_wms&#xA;ALTER COLUMN geom TYPE geometry(GEOMETRY, 4326)&#xA;USING ST_SetSRID(geom,4326);&#xA;CREATE INDEX visualisation_wms_gist_idx ON visualisation_wms USING GIST (geom); &#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;1382580250144-4&quot;>&#xA;        &lt;sql>&#xA;CREATE INDEX visualisation_wms_trip_idx  ON soop_trv.visualisation_wms  USING btree  (trip_id );&#xA;&#xA;ALTER TABLE visualisation_wms ADD CONSTRAINT visualisation_wms_pkey PRIMARY KEY (trip_id );&#xA;ALTER TABLE measurements_merged_data ADD COLUMN measurement bigserial;&#xA;ALTER TABLE measurements_merged_data ADD CONSTRAINT measurements_merged_data_pkey PRIMARY KEY (measurement );&#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;map_view&quot; runOnChange=&quot;true&quot;>&#xA;        &lt;sql>&#xA;           DROP VIEW IF EXISTS soop_trv_trajectory_map;&#xA;           CREATE VIEW soop_trv_trajectory_map AS &#xA;           SELECT a.trip_id,&#xA;            a.metadata_uuid, &#xA;            timezone('UTC'::text, a.time_coverage_start) AS time_coverage_start, &#xA;            timezone('UTC'::text, a.time_coverage_end) AS time_coverage_end, &#xA;            a.colour,&#xA;            a.&quot;TURB_b&quot;, &#xA;            a.&quot;CPHL_b&quot;, &#xA;            a.&quot;TEMP_b&quot;,&#xA;            a.&quot;PSAL_b&quot;, &#xA;            a.geom, &#xA;            (SELECT DISTINCT deployments.platform_code&#xA;             FROM deployments&#xA;             WHERE deployments.trip_id = a.trip_id) AS platform_code,&#xA;            (SELECT DISTINCT deployments.vessel_name&#xA;             FROM deployments&#xA;             WHERE deployments.trip_id = a.trip_id) AS vessel_name&#xA;            FROM visualisation_wms a;&#xA;    &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;data_view&quot; runOnChange=&quot;true&quot;>&#xA;        &lt;sql>&#xA;           DROP VIEW IF EXISTS soop_trv_trajectory_data;&#xA;CREATE OR REPLACE VIEW soop_trv_trajectory_data AS &#xA;SELECT measurements_merged_data.trip_id, &#xA;visualisation_wms.vessel_name,&#xA;timezone('UTC'::text, measurements_merged_data.&quot;TIME&quot;) AS &quot;TIME&quot;, &#xA;measurements_merged_data.&quot;LATITUDE&quot;, &#xA;measurements_merged_data.&quot;LONGITUDE&quot;, &#xA;measurements_merged_data.&quot;TURB&quot;, &#xA;measurements_merged_data.&quot;TEMP&quot;, &#xA;measurements_merged_data.&quot;PSAL&quot;, &#xA;measurements_merged_data.&quot;CPHL&quot;, &#xA;measurements_merged_data.&quot;TURB&quot; IS NOT NULL AS &quot;TURB_b&quot;, &#xA;measurements_merged_data.&quot;TEMP&quot; IS NOT NULL AS &quot;TEMP_b&quot;,&#xA;measurements_merged_data.&quot;PSAL&quot; IS NOT NULL AS &quot;PSAL_b&quot;,&#xA;measurements_merged_data.&quot;CPHL&quot; IS NOT NULL AS &quot;CPHL_b&quot;, &#xA;measurements_merged_data.geom&#xA;   FROM measurements_merged_data&#xA;   JOIN visualisation_wms ON visualisation_wms.trip_id = measurements_merged_data.trip_id&#xA;  ORDER BY trip_id, measurements_merged_data.&quot;TIME&quot;;&#xA;&#xA;    &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;createIndexOnMeasurementTables&quot; runOnChange=&quot;true&quot;>&#xA;        &lt;sql>&#xA;CREATE INDEX measurements_cphl_trip_id_idx&#xA;  ON soop_trv.measurements_cphl&#xA;  USING btree&#xA;  (trip_id, &quot;TIME&quot;);&#xA;&#xA;CREATE INDEX measurements_psal_trip_id_idx&#xA;  ON soop_trv.measurements_psal&#xA;  USING btree&#xA;  (trip_id, &quot;TIME&quot;);&#xA;&#xA;CREATE INDEX measurements_temp_trip_id_idx&#xA;  ON soop_trv.measurements_temp&#xA;  USING btree&#xA;  (trip_id, &quot;TIME&quot;);&#xA;&#xA;CREATE INDEX measurements_turb_trip_id_idx&#xA;  ON soop_trv.measurements_turb&#xA;  USING btree&#xA;  (trip_id, &quot;TIME&quot;);&#xA;&#xA;CREATE INDEX table_master_trip_id_idx&#xA;  ON soop_trv.table_master&#xA;  USING btree&#xA;  (trip_id, &quot;TIME&quot;);&#xA;    &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;createIndexOnMeasurementMergedTable&quot; runOnChange=&quot;true&quot;>&#xA;  &lt;sql>&#xA;    CREATE INDEX measurements_merged_data_gist_idx ON measurements_merged_data USING GIST (geom);&#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;createIndexOnMeasurementMergedTable_tripTime&quot; runOnChange=&quot;true&quot;>&#xA;  &lt;sql>&#xA;&#x9;CREATE INDEX measurements_mergedtriptime_idx ON measurements_merged_data USING btree (trip_id, &quot;TIME&quot;);&#xA;        CREATE INDEX measurements_mergedtrip_idx ON measurements_merged_data USING btree (trip_id);&#xA;  &lt;/sql>&#xA; &lt;/changeSet>&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;clean_dataFUNCTION&quot; runOnChange=&quot;true&quot; >&#xA;&lt;createProcedure>&#xA;&#xA;CREATE OR REPLACE FUNCTION clean_data(p_file_id integer)&#xA;  RETURNS void AS&#xA;'  declare&#xA;     v_url text;&#xA;     v_trip_id int;&#xA;  BEGIN&#xA;     select url into v_url from indexed_file where id = $1;&#xA;     select distinct trip_id into v_trip_id from deployments where &#xA;file_id = $1;&#xA;&#xA;     IF v_url ~ ''IMOS_SOOP-TRV_B'' THEN&#xA;           delete from  measurements_cphl  where file_id = $1;&#xA;           update measurements_merged_data set &quot;CPHL&quot; = NULL where  measurements_merged_data.trip_id = v_trip_id ;&#xA;     update  visualisation_wms set &quot;CPHL_b&quot; = false WHERE visualisation_wms.trip_id = v_trip_id ;&#xA;&#xA;     ELSIF v_url ~ ''IMOS_SOOP-TRV_S'' THEN&#xA;            delete from  measurements_psal  where file_id = $1;&#xA;            update measurements_merged_data set &quot;PSAL&quot; = NULL where measurements_merged_data.trip_id = v_trip_id ;&#xA;          update  visualisation_wms set &quot;PSAL_b&quot; = false WHERE visualisation_wms.trip_id = v_trip_id ;&#xA;&#xA;     ELSIF v_url ~ ''IMOS_SOOP-TRV_T'' THEN&#xA;          delete from  measurements_temp  where file_id = $1;&#xA;          update measurements_merged_data set &quot;TEMP&quot; = NULL where measurements_merged_data.trip_id = v_trip_id;&#xA;          update  visualisation_wms set &quot;TEMP_b&quot; = false WHERE visualisation_wms.trip_id = v_trip_id ;&#xA;&#xA;     ELSIF v_url ~ ''IMOS_SOOP-TRV_U'' THEN&#xA;          delete from  measurements_turb  where file_id = $1;&#xA;          update measurements_merged_data set &quot;TURB&quot; = NULL where measurements_merged_data.trip_id = v_trip_id ;&#xA;          update  visualisation_wms set &quot;TURB_b&quot; = false WHERE visualisation_wms.trip_id = v_trip_id ;&#xA;&#xA;     END IF;&#xA;    &#xA;     DELETE FROM measurements_merged_data where &quot;TURB&quot; IS NULL AND &quot;TEMP&quot; IS NULL AND &quot;CPHL&quot; IS NULL AND &quot;PSAL&quot; IS NULL and trip_id = v_trip_id ;&#xA;     DELETE FROM visualisation_wms where &quot;TURB_b&quot; IS False AND &quot;TEMP_b&quot; IS False AND &quot;CPHL_b&quot; IS False AND &quot;PSAL_b&quot; IS False and trip_id = v_trip_id ;&#xA;  &#xA;  END;'&#xA;  LANGUAGE plpgsql VOLATILE&#xA;&lt;/createProcedure>&#xA; &lt;/changeSet>&#xA;&#xA;&#xA;&lt;changeSet author=&quot;talend&quot; id=&quot;truncateCorruptedTableToReprocessAllWFSData&quot; runOnChange=&quot;true&quot;>&#xA;  &lt;sql>&#xA;     TRUNCATE measurements_merged_data;&#xA;  &lt;/sql>&#xA;&lt;/changeSet>&#xA;&#xA;&#xA;&lt;/databaseChangeLog>&#xA;"/>
SOOP_TRV/process/SOOP_TRV/SOOP_TRV_harvester_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;TRUNCATE TABLE table_master;&quot;&#xA;"/>
SRS_OC_LJCO_WWS/process/SRS_OC_LJCO_WWS/subjobs/harvestFile_daily_wqm_fv02_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;&#xA;TRUNCATE TABLE temporary_sub_select_wms_daily_wqm_fv02;&#xA;INSERT INTO temporary_sub_select_wms_daily_wqm_fv02 (&#xA;SELECT &quot; + context.file_id  + &quot; as file_id, &#xA;min(water.\&quot;TIME\&quot;) AS time_start, &#xA;max(water.\&quot;TIME\&quot;) AS time_end, &#xA;COUNT(water.\&quot;CNDC\&quot;) AS \&quot;CNDC\&quot;,&#xA;COUNT(water.\&quot;DENS\&quot;) AS \&quot;DENS\&quot;,&#xA;COUNT(water.\&quot;DEPTH\&quot;) AS \&quot;DEPTH\&quot;,&#xA;COUNT(water.\&quot;DOX1_1\&quot;) AS \&quot;DOX1_1\&quot;,&#xA;COUNT(water.\&quot;DOX1_2\&quot;) AS \&quot;DOX1_2\&quot;,&#xA;COUNT(water.\&quot;DOX1_3\&quot;) AS \&quot;DOX1_3\&quot;,&#xA;COUNT(water.\&quot;DOX2\&quot;) AS \&quot;DOX2\&quot;,&#xA;COUNT(water.\&quot;PRES_REL\&quot;) AS \&quot;PRES_REL\&quot;,&#xA;COUNT(water.\&quot;PSAL\&quot;) AS \&quot;PSAL\&quot;,&#xA;COUNT(water.\&quot;TEMP\&quot;) AS \&quot;TEMP\&quot;,&#xA;COUNT(water.\&quot;CHLF\&quot;) AS \&quot;CHLF\&quot;,&#xA;COUNT(water.\&quot;FLU2\&quot;) AS \&quot;FLU2\&quot;,&#xA;COUNT(water.\&quot;TURB_RAW_COUNT\&quot;) AS \&quot;TURB_RAW_COUNT\&quot;,&#xA;COUNT(water.\&quot;TURB\&quot;) AS \&quot;TURB\&quot;,&#xA;water.geom&#xA;FROM  measurements_daily_wqm_fv02 water where water.file_id = &quot; + context.file_id + &quot;&#xA;GROUP BY water.geom);&quot;"/>
SRS_OC_LJCO_WWS/process/SRS_OC_LJCO_WWS/subjobs/harvestFile_monthly_weather_fv01_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;&#xA;TRUNCATE TABLE temporary_sub_select_wms_mtw_monthly_fv01;&#xA;INSERT INTO temporary_sub_select_wms_mtw_monthly_fv01 (&#xA;SELECT &quot; + context.file_id  + &quot; as file_id, &#xA;min(water.\&quot;TIME\&quot;) AS time_start, &#xA;max(water.\&quot;TIME\&quot;) AS time_end, &#xA;COUNT(water.\&quot;WMXH_01\&quot;) AS \&quot;WMXH_01\&quot;,&#xA;COUNT(water.\&quot;WMXH_10\&quot;) AS \&quot;WMXH_10\&quot;,&#xA;COUNT(water.\&quot;WMXH_30\&quot;) AS \&quot;WMXH_30\&quot;,&#xA;COUNT(weather.\&quot;AIRT\&quot;) AS \&quot;AIRT\&quot;,&#xA;COUNT(weather.\&quot;ATMP\&quot;) AS \&quot;ATMP\&quot;,&#xA;COUNT(weather.\&quot;RELH\&quot;) AS \&quot;RELH\&quot;,&#xA;COUNT(weather.\&quot;WDIR\&quot;) AS \&quot;WDIR\&quot;,&#xA;COUNT(weather.\&quot;WSPD\&quot;) AS \&quot;WSPD\&quot;,&#xA;COUNT(weather.\&quot;WSPD_max\&quot;) AS \&quot;WSPD_max\&quot;,&#xA;water.geom&#xA;FROM  measurements_mtw_water_monthly_fv01 water, measurements_mtw_weather_monthly_fv01 weather where water.file_id = &quot; + context.file_id + &quot;&#xA;GROUP BY water.geom);&quot;&#xA;"/>
SRS_OC_LJCO_WWS/process/SRS_OC_LJCO_WWS/subjobs/harvestFile_hourly_wqm_fv01_0.1.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;&#xA;TRUNCATE TABLE temporary_sub_select_wms_hourly_wqm_fv01;&#xA;INSERT INTO temporary_sub_select_wms_hourly_wqm_fv01 (&#xA;SELECT &quot; + context.file_id  + &quot; as file_id, &#xA;min(water.\&quot;TIME\&quot;) AS time_start, &#xA;max(water.\&quot;TIME\&quot;) AS time_end, &#xA;COUNT(water.\&quot;CNDC\&quot;) AS \&quot;CNDC\&quot;,&#xA;COUNT(water.\&quot;DENS\&quot;) AS \&quot;DENS\&quot;,&#xA;COUNT(water.\&quot;DEPTH\&quot;) AS \&quot;DEPTH\&quot;,&#xA;COUNT(water.\&quot;DOX1_1\&quot;) AS \&quot;DOX1_1\&quot;,&#xA;COUNT(water.\&quot;DOX1_2\&quot;) AS \&quot;DOX1_2\&quot;,&#xA;COUNT(water.\&quot;DOX1_3\&quot;) AS \&quot;DOX1_3\&quot;,&#xA;COUNT(water.\&quot;DOX2\&quot;) AS \&quot;DOX2\&quot;,&#xA;COUNT(water.\&quot;PRES_REL\&quot;) AS \&quot;PRES_REL\&quot;,&#xA;COUNT(water.\&quot;PSAL\&quot;) AS \&quot;PSAL\&quot;,&#xA;COUNT(water.\&quot;TEMP\&quot;) AS \&quot;TEMP\&quot;,&#xA;COUNT(water.\&quot;CHLF\&quot;) AS \&quot;CHLF\&quot;,&#xA;COUNT(water.\&quot;FLU2\&quot;) AS \&quot;FLU2\&quot;,&#xA;COUNT(water.\&quot;TURB\&quot;) AS \&quot;TEMP\&quot;,&#xA;COUNT(water.\&quot;TURB_RAW_COUNT\&quot;) AS \&quot;TURB_RAW_COUNT\&quot;,&#xA;&#xA;water.geom&#xA;FROM  measurements_hourly_wqm_fv01 water where water.file_id = &quot; + context.file_id + &quot;&#xA;GROUP BY water.geom);&quot;&#xA;"/>
ANMN_NRS_DAR_YON_TS/process/ANMN_NRS_DAR_YON/subjobs/data_and_metadata_anmn_nrs_0.5.item:    <elementParameter field="MEMO_SQL" name="QUERY" value="&quot;TRUNCATE TABLE  timeseries_feature_deployments_final;&#xA;INSERT INTO timeseries_feature_deployments_final (&#xA;WITH &#xA;table_a AS(SELECT distinct file_id, measurements.channel_id   from measurements  ),&#xA;table_b AS(SELECT file_id, name AS \&quot;VARNAME\&quot; from variable where  ( variable.name !~ 'LATITUDE' AND  variable.name !~ 'LONGITUDE' AND variable.name !~ 'TIME' AND variable.name !~ '_quality_control')) ,&#xA;table_c AS (&#xA;         SELECT measurements.channel_id, min(measurements.\&quot;TIME\&quot;) AS time_start, max(measurements.\&quot;TIME\&quot;) AS time_end&#xA;           FROM measurements&#xA;          GROUP BY measurements.channel_id&#xA;        ),&#xA;data as (SELECT   channel_id, \&quot;LATITUDE\&quot; ,  \&quot;LONGITUDE\&quot; ,  \&quot;DEPTH\&quot; ,  geom ,  platform_code,platform_name from timeseries_feature_deployments)&#xA;&#xA;SELECT &#xA;distinct table_a.channel_id , platform_code ,platform_name ,&#xA;table_b.\&quot;VARNAME\&quot;  ,&#xA;\&quot;LATITUDE\&quot; ,  \&quot;LONGITUDE\&quot; ,  \&quot;DEPTH\&quot; ,     geom,table_c.time_start,table_c.time_end &#xA;&#xA;from data&#xA;&#xA;LEFT JOIN table_a  ON data.channel_id = table_a.channel_id&#xA;LEFT JOIN table_b  ON table_a.file_id = table_b.file_id&#xA;LEFT JOIN table_c  ON table_a.channel_id = table_c.channel_id);&#xA;&#xA;&quot;"/>

@jonescc
Copy link
Contributor

jonescc commented May 15, 2018

This is causing problems for imos:anmn_nrs_bgc_plankton_zooplankton_data for which wfs requests regulary fail at 6:04pm when the harvester is running as per https://github.com/aodn/backlog/issues/836.

Read requests must wait until changes containing a truncate are committed. If this takes a while wfs requests time out waiting.

@mhidas
Copy link
Contributor Author

mhidas commented May 15, 2018

Can we do a bulk update to fix all the harvesters?

@jonescc
Copy link
Contributor

jonescc commented May 15, 2018

We can do that, but developers don't really know what these harvesters are meant to do/how to verify that they are still working correctly after the changes which is why I think this was raised in the harvesters repo. Making the changes shouldn't be that hard.

@mhidas
Copy link
Contributor Author

mhidas commented Jun 3, 2019

It doesn't look like we've made any progress with this. I won't dump the full grep from above, but these harvesters still include at least one TRUNCATE:
AATAMS_ACOUSTIC_QC
ANMN_MHLWAVE
ANMN_NRS_BGC
ANMN_NRS_DAR_YON_TS
AODN_CSIRO_CMAR
AODN_WAVE_NRT
AUS_PHYTO_DB
AUV
AUV_VIEWER_TRACKS
SOOP_BA
SOOP_TRV
SRS_ALTIMETRY
SRS_LJCO_AERONET_TS
SRS_OC_LJCO_WWS
SRS_OC_SOOP_RAD
WODB

Has this led to any more data availability issues recently? Do we need to prioritise this?

Making the changes shouldn't be that hard.

Not hard, just time-consuming, if we need to do it by clicking around in TOS. Of course changing "TRUNCATE" to "CLEAR" can be done with a simple search/replace on the relevant "process/*.item" files, but testing the updated harvester takes a bit more time. Maybe the harvester tests developed for the TOS7 upgrade could also help with this?

@mhidas
Copy link
Contributor Author

mhidas commented Jun 3, 2019

Also we need to be careful doing just a simple grep for "TRUNCATE" and replacing it with "CLEAR". I just noticed that some of the harvesters above use "TRUNCATE TABLE x;" in SQL inside the liquibase script (e.g. ANMN_NRS_DAR_YON_TS and AUV). In these cases the replacement string should be "DELETE FROM x;" I guess?

@lbesnard
Copy link
Contributor

lbesnard commented Jun 3, 2019

why changing what is not broken ?

@jonescc
Copy link
Contributor

jonescc commented Jun 3, 2019

Note that this is broken. See #507 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants