NCAR / kcor-pipeline

Pipeline code for KCor
Other
3 stars 2 forks source link

Fix database errors with kcor_hw in 2.1.11 reprocessing #382

Closed mgalloy closed 2 months ago

mgalloy commented 3 months ago

There are several database errors that involve kcor_hw are frequently reported in the logs.

The first is:

2024-07-29 22:35:01 WARN: KCOR_HW_INSERT: cannot find 20240409_174852_kcor_l2_pb.fts.gz

That file is there:

level2$ ll 20240409_174852_kcor_l2_pb.fts.gz
-rw-rw-r--. 1 mgalloy cordyn 2.5M Jul 29 20:19 20240409_174852_kcor_l2_pb.fts.gz

Maybe it was not there when it was needed? Maybe it was just .fts then?

Next is:

2024-07-29 22:35:23 ERROR: KCORDBMYSQL::REPORT_ERROR: error with SQL statement
2024-07-29 22:35:23 ERROR: KCORDBMYSQL::REPORT_ERROR: status: 1
2024-07-29 22:35:23 ERROR: KCORDBMYSQL::REPORT_ERROR: Cannot add or update a child row: a foreign key
constraint fails (`MLSO`.`kcor_eng`, CONSTRAINT `kcor_eng_ibfk_4` FOREIGN KEY (`kcor_hw_id`)
REFERENCES `kcor_hw` (`hw_id`))
2024-07-29 22:35:23 ERROR: KCORDBMYSQL::REPORT_ERROR: SQL command: insert into kcor_eng (file_name,
date_obs, obs_day, rcamfocs, tcamfocs, modltrt, o1focs, kcor_sgsdimv, kcor_sgsdims, level, bunit,
bzero, bscale, rcamxcen, rcamycen, tcamxcen, tcamycen, rcam_rad, tcam_rad, image_scale, mean_phase1,
cover, darkshut, diffuser, calpol, distort, labviewid, socketcamid, kcor_sw_id, kcor_hw_id) values
('20240409_174852_kcor_l2_pb.fts', '2024-04-09T17:48:52', 10132, 0.000000, 0.000000, 31.900000,
133.834000, 8.083000, 0.008747, 3, 'Mean Solar Brightness', 0, 1.000000, 515.299988, 512.299988,
513.229980, 515.229980, 177.759995, 180.820007, 5.614600, 0.000000, 'out', 'out', 'out', 'out',
'dist_coeff_20191216_212805_kcor_darkcorrected_occulter_in_focus.sav', '20191125T093731',
'socketcam.exe', 123308, 0)
mgalloy commented 3 months ago

Fixed issues with duplicated entries for 20240330.

mgalloy commented 2 months ago

A problem with the kcor_hw table in general is that the pipeline is never quite sure when a "new" set of hardware settings is needed. It would probably be best to just copy the contents of kcor_hw into kcor_eng. I think the following would do it:

update kcor_eng
set kcor_eng.EACH_COLUMN = kcor_hw.EACH_COLUMN
from kcor_eng
left join kcor_hw
  on kcor_eng.kcor_hw_id = kcor_hw.hw_id
where kcor_hw.EACH_COLUMN is not null;
mgalloy commented 2 months ago

I think this OK now, but need to reprocess again to make sure. Will reprocess along with #365.

mgalloy commented 2 months ago

This looks good.