Error database upgrade 2.4.5 to 2.4.7-1: with possible workaround?

We’ve been running into an error while updating to 2.4.7-1. The database script aborts while trying to CREATE TABLE “usage_stats_temporary_records”:
-1: ERROR: null value in column "entry_time" violates not-null constraint

Inspired by the comment to disable the “NOTNULL” flag for the “entry_time” column in this discussion http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=11541, we commented out the “NOTNULL” flag in the schema.xml and ran the update successfully.

Relevant path: plugins/generic/usageStats/schema.xml

Would you advise approaching this problem differently? The “usage_states_temporary_records” doesn’t even have the “entry_time” column in the updated database. At least in our test.

Thank you!
Richard

Hi @rshiggin,

That suggests that there’s an entry in the timed_views_log table with a date column set to null. That in turn is a NOT NULL column so there should be no null data there . Can you check that table’s contents?

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks, Alec. We don’t have a timed_views_log table in our database, not on our version that isn’t updated, nor on the test version that is. I’m going to consult with the previous admin to see if it’s missing intentionally – I doubt it, though.

I should mention that we’ve been running our own statistics when the various iterations of stats functions (going back to COUNTER and perhaps before) haven’t worked for us. We have 25+ journals on one instance: http://scholarworks.iu.edu/journals.

Thanks for your help.
Richard

Hi @rshiggin,

Hmm, can you post the full output of the upgrade process? If you’re running OJS 2.4.5, the upgrade process shouldn’t trigger migrateTimedViewsUsageStatistics, which I think is where you are when this failure happens. That should only run for OJS 2.4.2 and older.

Regards,
Alec Smecher
Public Knowledge Project Team

I don’t have documentation on our last update, but I know there have been some struggles with the stats functions on previous updates for us. I’d prefer to push past this with my current workaround, and/or restoring what we absolutely need for core functions. Like I said before, we’ve been relying on our own scripts for statistics and don’t have the need to migrate old stats. I would very much appreciate any insight into the output, though. Our output was verbose (over the character limit here), so I’m going to post the very beginning and then our stack trace.

(postgres7): SELECT * FROM versions WHERE current = 1
(postgres7): SELECT * FROM versions WHERE current = 1 AND product_type = ? AND product = ? [ (0=>‘core’) (1=>‘ojs2’) ]
(postgres7): select version()
(postgres7): SELECT c.relname as “Name”, i.indisunique as “Unique”, i.indkey as “Columns” FROM pg_catalog.pg_class c JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid WHERE (c2.relname=‘signoffs’ or c2.relname=lower(‘signoffs’)) AND i.indisprimary=false;
(postgres7): SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum FROM pg_class c, pg_attribute a,pg_type t WHERE relkind in (‘r’,‘v’) AND (c.relname=‘signoffs’ or c.relname = lower(‘signoffs’)) and a.attname not like ‘…%’ AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum
(postgres7): SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = ‘signoffs’
(postgres7): SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname=‘signoffs’ order by d.adnum
(postgres7): SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum FROM pg_class c, pg_attribute a,pg_type t WHERE relkind in (‘r’,‘v’) AND (c.relname=‘signoffs’ or c.relname = lower(‘signoffs’)) and a.attname not like ‘…%’ AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum
(postgres7): SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = ‘signoffs’
(postgres7): SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname=‘signoffs’ order by d.adnum
(postgres7): SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum FROM pg_class c, pg_attribute a,pg_type t WHERE relkind in (‘r’,‘v’) AND (c.relname=‘signoffs’ or c.relname = lower(‘signoffs’)) and a.attname not like ‘…%’ AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum
(postgres7): SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = ‘signoffs’
(postgres7): SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname=‘signoffs’ order by d.adnum
(postgres7): SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum FROM pg_class c, pg_attribute a,pg_type t WHERE relkind in (‘r’,‘v’) AND (c.relname=‘signoffs’ or c.relname = lower(‘signoffs’)) and a.attname not like ‘…%’ AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum
(postgres7): SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = ‘signoffs’
(postgres7): SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname=‘signoffs’ order by d.adnum
(postgres7): SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum FROM pg_class c, pg_attribute a,pg_type t WHERE relkind in (‘r’,‘v’) AND (c.relname=‘signoffs’ or c.relname = lower(‘signoffs’)) and a.attname not like ‘…%’ AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum
(postgres7): SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = ‘signoffs’
(postgres7): SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname=‘signoffs’ order by d.adnum
(postgres7): SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname=‘signoffs_signoff_id_seq’ AND relkind=‘S’ AND deptype=‘i’
(postgres7): DROP INDEX signoff_symbolic
(postgres7): BEGIN
(postgres7): SELECT * INTO TEMPORARY TABLE signoffs_tmp FROM signoffs
(postgres7): DROP TABLE signoffs CASCADE
(postgres7): DROP SEQUENCE IF EXISTS signoffs_signoff_id_seq
(postgres7): CREATE TABLE signoffs ( signoff_id SERIAL, symbolic VARCHAR(32) NOT NULL, assoc_type INT8 DEFAULT 0 NOT NULL, assoc_id INT8 DEFAULT 0 NOT NULL, user_id INT8 NOT NULL, file_id INT8, file_revision INT8, date_notified TIMESTAMP, date_underway TIMESTAMP, date_completed TIMESTAMP, date_acknowledged TIMESTAMP, user_group_id INT8, PRIMARY KEY (signoff_id) )
(postgres7): INSERT INTO signoffs (signoff_id, symbolic, assoc_type, assoc_id, user_id, file_id, file_revision, date_notified, date_underway, date_completed, date_acknowledged, user_group_id) SELECT signoff_id, symbolic, assoc_type, assoc_id, user_id, file_id, file_revision, date_notified, date_underway, date_completed, date_acknowledged, user_group_id FROM signoffs_tmp
(postgres7): SELECT setval(‘signoffs_signoff_id_seq’,MAX(signoff_id)) FROM signoffs
(postgres7): DROP TABLE signoffs_tmp
(postgres7): COMMIT


about 60,000 characters omitted

(postgres7): BEGIN
(postgres7): SELECT * INTO TEMPORARY TABLE usage_stats_temporary_records_tmp FROM usage_stats_temporary_records
(postgres7): DROP TABLE usage_stats_temporary_records CASCADE
(postgres7): CREATE TABLE usage_stats_temporary_records ( assoc_id INT8 NOT NULL, assoc_type INT8 NOT NULL, day INT8 NOT NULL, metric INT8 DEFAULT 1 NOT NULL, country_id VARCHAR(2), region VARCHAR(2), city VARCHAR(255), load_id VARCHAR(255) NOT NULL, file_type SMALLINT, entry_time INT8 NOT NULL )
(postgres7): INSERT INTO usage_stats_temporary_records (assoc_id, assoc_type, day, metric, country_id, region, city, load_id, file_type, entry_time) SELECT assoc_id, assoc_type, day, metric, country_id, region, city, load_id, file_type, entry_time FROM usage_stats_temporary_records_tmp
-1: ERROR: null value in column “entry_time” violates not-null constraint
ADOConnection._Execute(INSERT INTO usage_stats_temporary_records (assoc_id, assoc_type, day, metric, country_id, region, city, load_id, file_type, entr…, false) % line 864, file: adodb.inc.php
ADOConnection.Execute(INSERT INTO usage_stats_temporary_records (assoc_id, assoc_type, day, metric, country_id, region, city, load_id, file_type, entr…) % line 452, file: Installer.inc.php
Installer.executeSQL(INSERT INTO usage_stats_temporary_records (assoc_id, assoc_type, day, metric, country_id, region, city, load_id, file_type, entr…) % line 447, file: Installer.inc.php
Installer.executeSQL(Array[7]) % line 695, file: PKPPlugin.inc.php
PKPPlugin.updateSchema(Installer::postInstall, Array[2]) % line 0, file:
(postgres7): SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ? AND journal_id = ? [ (0=>‘usagestatsplugin’) (1=>‘0’) ]
-1: ERROR: current transaction is aborted, commands ignored until end of transaction block
ADOConnection._Execute(SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ? AND journal_id = ?, Array[2]) % line 860, file: adodb.inc.php
ADOConnection.Execute(SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ? AND journal_id = ?, Array[2]) % line 98, file: DAO.inc.php
DAO.retrieve(SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ? AND journal_id = ?, Array[2]) % line 77, file: PluginSettingsDAO.inc.php
PluginSettingsDAO.getPluginSettings(0, usagestatsplugin) % line 253, file: PluginSettingsDAO.inc.php
PluginSettingsDAO.installSettings(0, usagestatsplugin, plugins/generic/usageStats/settings.xml) % line 0, file:
DB Error: ERROR: current transaction is aborted, commands ignored until end of transaction block

Stack Trace:

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/classes/plugins/PluginSettingsDAO.inc.php line 77
Function: DAO->retrieve(“SELECT setting_name, setting_value, setting_type FROM plugin_set…”, Array(2))

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/classes/plugins/PluginSettingsDAO.inc.php line 253
Function: PluginSettingsDAO->getPluginSettings(0"usagestatsplugin")

File: (unknown) line (unknown)
Function: PluginSettingsDAO->installSettings(0"usagestatsplugin", “plugins/generic/usageStats/settings.xml”)

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/classes/plugins/PKPPlugin.inc.php line 533
Function: call_user_func_array(Array(2), Array(3))

File: (unknown) line (unknown)
Function: PKPPlugin->installSiteSettings(“Installer::postInstall”, Array(2))

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/classes/plugins/HookRegistry.inc.php line 89
Function: call_user_func(Array(2), “Installer::postInstall”, Array(2))

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/classes/install/Installer.inc.php line 208
Function: HookRegistry->call(“Installer::postInstall”, Array(2))

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/classes/install/Installer.inc.php line 194
Function: Installer->postInstall()

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/classes/install/form/UpgradeForm.inc.php line 50
Function: Installer->execute()

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/pages/install/PKPInstallHandler.inc.php line 114
Function: UpgradeForm->execute()

File: (unknown) line (unknown)
Function: PKPInstallHandler->installUpgrade(Array(0), Object(Request))

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/classes/core/PKPRouter.inc.php line 362
Function: call_user_func(Array(2), Array(0), Object(Request))

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/classes/core/PKPPageRouter.inc.php line 220
Function: PKPRouter->_authorizeInitializeAndCallRequest(Array(2), Object(Request), Array(0), False)

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/classes/core/Dispatcher.inc.php line 134
Function: PKPPageRouter->route(Object(Request))

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/lib/pkp/classes/core/PKPApplication.inc.php line 178
Function: Dispatcher->dispatch(Object(Request))

File: /srv/www/scholarworks.iu.edu/htdocs/ojs-2.4.7-1/index.php line 64
Function: PKPApplication->execute()

Hi @rshiggin,

If you don’t need statistics, then you should be fine to use your work-around – but when you’re finished, I’d suggest truncating the usage_stats_temporary_records table entirely and re-introducing the NOT NULL constraint using an ALTER TABLE command in the MySQL client.

Regards,
Alec Smecher
Public Knowledge Project Team

Great! Thanks so much for your help, Alec.

All the best,
Richard

I encountered extactly the same problem upgrading from 2.4.7.0 to 2.4.7.1

I followed the same process of commenting out the “NOTNULL” entries in plugins/generic/usageStats/schema.xml (Thank you, rshiggin, for the suggestion.

Finally the database upgrade worked although I didn’t get a success message. I simply went back to the site and the correct information seemed to be there.

I have left the “NOTNULL” entries commented out.

I have done several upgrades successfully before and I have not encountered any problem like this.

Is there an inherent problem?

Graham

Hi @GrahamShepherd,

I tested here, upgrading from 2.4.7-0 to 2.4.7-1, and I had no problem. It’s strange that you have this problem upgrading from this version because nothing changed on that table between those two versions.

Are you sure you were coming from 2.4.7-0?

Thanks,
Bruno

Thanks, Bruno.

Yes, I am absolutely sure it was 2.4.7.0. I have implemented every upgrade as soon as it has come out but this is the first time I have encountered a problem.

Graham

@GrahamShepherd,

Do you still have any backups from that installation? If that’s possible, can you send me? I don’t think I need the users information, so you can just erase that table.

It that’s ok, it will make much easier the debugging from my side. Thanks,

Bruno