ElvishArtisan / rivendell

A full-featured radio automation system targeted for use in professional broadcast and media environments
205 stars 64 forks source link

Error When Attempting to Merge Traffic #878

Closed dklann closed 1 year ago

dklann commented 1 year ago

Using version 4.0.0rc2-1 from the Paravel repository on Linux Mint 21, up-to-date.

Here is the output of dpkg-query --no-pager --list \*rivendell\*

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name               Version      Architecture Description
+++-==================-============-============-=============================================
ii  rivendell          4.0.0rc2-1   amd64        Radio Broadcast Automation System
ii  rivendell-opsguide 4.0.0rc2-1   all          Rivendell Operations and Administration Guide
un  rivendell-pypad    <none>       <none>       (no description available)

What I Did

Defined a custom traffic import template and proceeded to test traffic import. image

What I Expected To Happen

I expected to see a successful test and then be able to merge traffic with a generated log.

What Happened

The test failed and I observed the following error in the system journal:

invalid SQL or failed DB connection[Unknown column 'TFC_TRANS_TYPE_OFFSET' in 'field list' QMYSQL: Unable to execute query]: select `TFC_CART_OFFSET`,`TFC_CART_LENGTH`,`TFC_DATA_OFFSET`,`TFC_DATA_LENGTH`,`TFC_EVENT_ID_OFFSET`,`TFC_EVENT_ID_LENGTH`,`TFC_ANNC_TYPE_OFFSET`,`TFC_ANNC_TYPE_LENGTH`,`TFC_TITLE_OFFSET`,`TFC_TITLE_LENGTH`,`TFC_HOURS_OFFSET`,`TFC_HOURS_LENGTH`,`TFC_MINUTES_OFFSET`,`TFC_MINUTES_LENGTH`,`TFC_SECONDS_OFFSET`,`TFC_SECONDS_LENGTH`,`TFC_LEN_HOURS_OFFSET`,`TFC_LEN_HOURS_LENGTH`,`TFC_LEN_MINUTES_OFFSET`,`TFC_LEN_MINUTES_LENGTH`,`TFC_LEN_SECONDS_OFFSET`,`TFC_LEN_SECONDS_LENGTH`,`TFC_TRANS_TYPE_OFFSET`,`TFC_TRANS_TYPE_LENGTH`,`TFC_TIME_TYPE_OFFSET`,`TFC_TIME_TYPE_LENGTH` from `SERVICES` where `NAME`='Production'

And the same thing for the following three columns:

How I Worked Around The Issue

I manually added those columns to the SERVICES table in the database and the traffic import test succeeded. Then generated a log and successfully merged traffic.

More Discussion

I searched for those four column-name strings in the source tree with grep -E -r '(MUS|TFC)_(TIME|TRANS)_TYPE_(LENTGH|OFFSET)' .). The only "grep hits" were references to the MUS instances of the column names. There were no references to the TFC columns in the code.

Maybe the TFC columns were missed in commit 7c8fbeacb841 when the MUS columns were added to the database schema?

ElvishArtisan commented 1 year ago

Unable to reproduce here.

What was the providence of the Rivendell database used here? Was it created anew, or was it from an earlier version of Rivendell that was updated to v4.0.0rc2? Any chance that I could get a copy of the DB, along with a sample traffic import file?

dklann commented 1 year ago

Thanks for checking Fred! As far as I know, this started as a "jammy" "repo-installed" Rivendell instance on Mint 21. The install happened before I started working with this station. On 31 March I updated to current (all packages, including rivendell) using apt-get dist-upgrade. We had not attempted importing traffic using the previous (4.0.0rc0-1) version of Rivendell.

Unfortunately, the backup from before I modified the database has already aged out. I'll send a current copy of the database and a traffic import via direct email.

Since you're unable to reproduce the problem, are you saying that your database includes these columns?

I don't see any code that mentions these column names in utils/rddbmgr/updateschema.cpp

I do see this code in the method RDSvc::import in lib/rdsvc.cpp (starting at line 531) where it would refer to those column names:

sql=QString("select ")+
...
"`"+src_str+"TRANS_TYPE_OFFSET`,"+   // 22
"`"+src_str+"TRANS_TYPE_LENGTH`,"+   // 23
...

Thanks for your thoughts on this!

ElvishArtisan commented 1 year ago

Received the DB. Thank you.

Still unable to reproduce the problem. In addition to the environment you documented above (Mint 21 w/ DEB packages), I've tried current Git 'qt5', on both Mint 21 and CentOS 7. In all cases, the log was merged as expected with no errors or exceptions. (See your e-mail for a listing).

This one's a bit of a puzzler...

ElvishArtisan commented 1 year ago

Since you're unable to reproduce the problem, are you saying that your database includes these columns?

TFC_TIME_TYPE_LENGTH TFC_TIME_TYPE_OFFSET TFC_TRANS_TYPE_LENGTH TFC_TRANS_TYPE_OFFSET

They are not present, nor should they be.

I do see this code in the method RDSvc::import in lib/rdsvc.cpp (starting at line 531) where it would refer to those column names:

So we do have a potential code path that could generate them. That should only be called with ```src_str="MUS";''' though. Gives us some bread crumbs to follow though.

ElvishArtisan commented 1 year ago

'Kay, I was finally able to reproduce this here.

ElvishArtisan commented 1 year ago

The test DB you sent contains the following fields that are not part of the base schema:

Did you add these manually (perhaps in the course of troubleshooting), or did they just appear on their own?

dklann commented 1 year ago

Yes, I manually submitted the necessary ALTER TABLE SQL statements to add those four columns.

ElvishArtisan commented 1 year ago

Cool. That was the answer I was hoping for. :)

ElvishArtisan commented 1 year ago

Fixed in 73dd55b. Please test (without the added fields).

dklann commented 1 year ago

Wow. Quick! Thanks, I'll test as soon as I have a moment to build and run that commit...

ElvishArtisan commented 1 year ago

Wow. Quick!

Truth be told, I had that commit lined up and waiting. Just needed to be sure that we didn't have something that was generating those two "oddball" fields first.

dklann commented 1 year ago

Confirmed working here. Thanks again for the fix @ElvishArtisan.