DB Errors after 3.2.0-2 to 3.3.0-6 upgrade

OK, so we have a problem and I’m looking for someone who could help. Anyone willing to consult on this for us? We would love to hire someone to help fix this as soon as practicable, or at least provide some direction. It seems that after the upgrade from 3.2.0-2 to 3.3.0-6 there are some database issues, but these were not discovered until after the backup was overwritten (oh no…). We are having trouble with submissions to the site, and editing existing journals.

[php7:error] PHP Fatal error:  Uncaught Error: Call to a member function getData() on null in /var/www/journal/plugins/generic/htmlArticleGalley/HtmlArticleGalleyPlugin.inc.php:109\nStack trace:\n#0 /var/www/journal/lib/pkp/classes/plugins/HookRegistry.inc.php(107): HtmlArticleGalleyPlugin->articleDownloadCallback('ArticleHandler:...', Array)\n#1 /var/www/journal/pages/article/ArticleHandler.inc.php(421): HookRegistry::call('ArticleHandler:...', Array)\n#2 /var/www/journal/lib/pkp/classes/core/PKPRouter.inc.php(395): ArticleHandler->download(Array, Object(Request))\n#3 /var/www/journal/lib/pkp/classes/core/PKPPageRouter.inc.php(246): PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(Request), Array, false)\n#4 /var/www/journal/lib/pkp/classes/core/Dispatcher.inc.php(144): PKPPageRouter->route(Object(Request))\n#5 /var/www/journal/lib/pkp/classes/core/PKPApplication.inc.php(362): Dispatcher->dispatch(Object(Request))\n#6 /var/www/journal/index.php(68): PKPApplication->execute()\n#7 {main}\n  thrown in /var/www/journal/plugins/generic/htmlArticleGall ey/HtmlArticleGalleyPlugin.inc.php on line 109

It seems that the migration failed; really need help figuring out how to stabilize the install. I’m happy to get some pointers, but I’m not very familiar with the internals of the software and would love to hire someone to look at it with me.

Thanks!

Hi @the_reis

Sorry to hear that the upgrade didn’t go so well. If you have someone who can look at the database a bit, here’s a pointer. That line of code, line 109 in the HtmlArticleGalleyPlugin, is this:

There are several calls to getData() on it, but the thing that is probably triggering the error is a null submission file, since there is a test for a null galley object a few lines up that would return false before line 109 was reached. So, I’d probably look in the publication_galleys table for submission_file_id columns that are either null, or do not exist in the files table any more. You can try running this query:

SELECT * FROM publication_galleys WHERE submission_file_id NOT IN (SELECT distinct file_id from files);

That would give you galleys that have invalid files, and from there you can work back to the publication object in the publications table, and from there you can get back to the submission object based on the submission_id column and then look in the workflow at that submission and see what’s up.

Good luck!

Jason

OK, that’s a good start, thank you.

Thank you Jason - It seems that the galleys with invalid files are all galleys starting with id 782.

It’s looking like something may have happened during _migrateSubmissionFiles in classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php

The submissions_files table still has the new_file_id column…

mysql> describe submission_files;
+--------------------+---------------------+------+-----+---------+----------------+
| Field              | Type                | Null | Key | Default | Extra          |
+--------------------+---------------------+------+-----+---------+----------------+
| file_id            | bigint(20)          | NO   | PRI | NULL    | auto_increment |
| revision           | bigint(20)          | NO   | PRI | NULL    |                |
| source_file_id     | bigint(20)          | YES  |     | NULL    |                |
| source_revision    | bigint(20)          | YES  |     | NULL    |                |
| submission_id      | bigint(20)          | NO   | MUL | NULL    |                |
| file_type          | varchar(255)        | NO   |     | NULL    |                |
| file_size          | bigint(20)          | NO   |     | NULL    |                |
| original_file_name | varchar(127)        | YES  |     | NULL    |                |
| file_stage         | bigint(20)          | NO   |     | NULL    |                |
| viewable           | tinyint(4)          | YES  |     | NULL    |                |
| date_uploaded      | datetime            | NO   |     | NULL    |                |
| date_modified      | datetime            | NO   |     | NULL    |                |
| assoc_id           | bigint(20)          | YES  |     | NULL    |                |
| genre_id           | bigint(20)          | YES  |     | NULL    |                |
| direct_sales_price | varchar(255)        | YES  |     | NULL    |                |
| sales_type         | varchar(255)        | YES  |     | NULL    |                |
| uploader_user_id   | bigint(20)          | YES  |     | NULL    |                |
| assoc_type         | bigint(20)          | YES  |     | NULL    |                |
| new_file_id        | bigint(20) unsigned | YES  |     | NULL    |                |
+--------------------+---------------------+------+-----+---------+----------------+
19 rows in set (0.00 sec)

Has anyone seen this before? Any thoughts on this?

Hi @the_reis

If you search through that file for new_file_id, you’ll see that it eventually gets renamed to file_id here:

But before that happens, the file_id column in your table should have been renamed to submission_file_id (it’s the line just prior).

This is a guess, but given that that’s the first time a column is renamed in that table during this process, does your MySQL user have ALTER TABLE privilege?

The problem is that right now we’re left with the fact that a substantial amount of the upgrade process did not run here.

Another curiosity, in that OJS 3.3 requires a) InnoDB database tables because it uses foreign keys for the first time ever, and b) creating a foreign key requires that the user has the REFERENCES mysql privilege.

Cheers,
Jason

Also, and perhaps you’ve already investigated this. I know you said that the backup was overwritten but does the systems admin have a server level backup that you can just restore back to? A nightly backup of the entire machine?

So I was able to walk through the steps and found where the upgrade stopped processing, and was able to complete the DB upgrade, and things look good. This isn’t pretty, I’ll acknowledge, and really not sure what happened, but alas things look good and consistent.

However, now when loading any page, I am getting a blank page and the following in the error logs:

Starting to look into this one now, but not finding this column in the upgrade scripts/classes.

PHP Fatal error:  Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'locale' in 'field list' in /var/www/journal/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:78
Stack trace:
#0 /var/www/journal/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(78): PDO->prepare('select `locale`...', Array)
#1 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(331): Doctrine\\DBAL\\Driver\\PDOConnection->prepare('select `locale`...')
#2 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(664): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select `locale`...', Array)
#3 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(631): Illuminate\\Database\\Connection->runQueryCallback('select `locale`...', Array, Object(Closure))
#4 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(339): Illuminate\\Database\\Connection->run('select `locale`...', Array, Object(Closure))
#5 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2270): Illuminate\\Database\\Connection->select('select `locale`...', Array, true)
#6 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2258): Illuminate\\Database\\Query\\Builder->runSelect()
#7 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2753): Illuminate\\Database\\Query\\Builder->Illuminate\\Database\\Query\\{closure}()
#8 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2259): Illuminate\\Database\\Query\\Builder->onceWithColumns(Array, Object(Closure))
#9 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(143): Illuminate\\Database\\Query\\Builder->get(Array)
#10 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2244): Illuminate\\Database\\Query\\Builder->first(Array)
#11 /var/www/journal/lib/pkp/classes/publication/PKPPublicationDAO.inc.php(57): Illuminate\\Database\\Query\\Builder->value('locale')
#12 /var/www/journal/classes/publication/PublicationDAO.inc.php(39): PKPPublicationDAO->_fromRow(Array)
#13 /var/www/journal/lib/pkp/classes/db/DAOResultFactory.inc.php(94): PublicationDAO->_fromRow(Array)
#14 /var/www/journal/lib/pkp/classes/db/DAOResultIterator.inc.php(33): DAOResultFactory->next()
#15 /var/www/journal/lib/pkp/classes/db/DAOResultFactory.inc.php(176): DAOResultIterator->__construct(Object(DAOResultFactory))
#16 /var/www/journal/lib/pkp/classes/services/PKPPublicationService.inc.php(80): DAOResultFactory->toIterator()
#17 /var/www/journal/lib/pkp/classes/submission/PKPSubmissionDAO.inc.php(93): PKP\\Services\\PKPPublicationService->getMany(Array)
#18 /var/www/journal/lib/pkp/classes/db/DAOResultFactory.inc.php(94): PKPSubmissionDAO->_fromRow(Array)
#19 /var/www/journal/lib/pkp/classes/db/DAOResultIterator.inc.php(33): DAOResultFactory->next()
#20 /var/www/journal/lib/pkp/classes/db/DAOResultFactory.inc.php(176): DAOResultIterator->__construct(Object(DAOResultFactory))
#21 /var/www/journal/lib/pkp/classes/services/PKPSubmissionService.inc.php(106): DAOResultFactory->toIterator()
#22 /var/www/journal/pages/issue/IssueHandler.inc.php(319): PKP\\Services\\PKPSubmissionService->getMany(Array)
#23 /var/www/journal/pages/index/IndexHandler.inc.php(62): IssueHandler::_setupIssueTemplate(Object(Request), Object(Issue))
#24 /var/www/journal/lib/pkp/classes/core/PKPRouter.inc.php(395): IndexHandler->index(Array, Object(Request))
#25 /var/www/journal/lib/pkp/classes/core/PKPPageRouter.inc.php(246): PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(Request), Array, false)
#26 /var/www/journal/lib/pkp/classes/core/Dispatcher.inc.php(144): PKPPageRouter->route(Object(Request))
#27 /var/www/journal/lib/pkp/classes/core/PKPApplication.inc.php(362): Dispatcher->dispatch(Object(Request))
#28 /var/www/journal/index.php(68): PKPApplication->execute()
#29 {main}

Next Doctrine\\DBAL\\Driver\\PDO\\Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'locale' in 'field list' in /var/www/journal/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18
Stack trace:
#0 /var/www/journal/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(83): Doctrine\\DBAL\\Driver\\PDO\\Exception::new(Object(PDOException))
#1 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(331): Doctrine\\DBAL\\Driver\\PDOConnection->prepare('select `locale`...')
#2 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(664): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select `locale`...', Array)
#3 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(631): Illuminate\\Database\\Connection->runQueryCallback('select `locale`...', Array, Object(Closure))
#4 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(339): Illuminate\\Database\\Connection->run('select `locale`...', Array, Object(Closure))
#5 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2270): Illuminate\\Database\\Connection->select('select `locale`...', Array, true)
#6 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2258): Illuminate\\Database\\Query\\Builder->runSelect()
#7 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2753): Illuminate\\Database\\Query\\Builder->Illuminate\\Database\\Query\\{closure}()
#8 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2259): Illuminate\\Database\\Query\\Builder->onceWithColumns(Array, Object(Closure))
#9 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(143): Illuminate\\Database\\Query\\Builder->get(Array)
#10 /var/www/journal/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2244): Illuminate\\Database\\Query\\Builder->first(Array)
#11 /var/www/journal/lib/pkp/classes/publication/PKPPublicationDAO.inc.php(57): Illuminate\\Database\\Query\\Builder->value('locale')
#12 /var/www/journal/classes/publication/PublicationDAO.inc.php(39): PKPPublicationDAO->_fromRow(Array)
#13 /var/www/journal/lib/pkp/classes/db/DAOResultFactory.inc.php(94): PublicationDAO->_fromRow(Array)
#14 /var/www/journal/lib/pkp/classes/db/DAOResultIterator.inc.php(33): DAOResultFactory->next()
#15 /var/www/journal/lib/pkp/classes/db/DAOResultFactory.inc.php(176): DAOResultIterator->__construct(Object(DAOResultFactory))
#16 /var/www/journal/lib/pkp/classes/services/PKPPublicationService.inc.php(80): DAOResultFactory->toIterator()
#17 /var/www/journal/lib/pkp/classes/submission/PKPSubmissionDAO.inc.php(93): PKP\\Services\\PKPPublicationService->getMany(Array)
#18 /var/www/journal/lib/pkp/classes/db/DAOResultFactory.inc.php(94): PKPSubmissionDAO->_fromRow(Array)
#19 /var/www/journal/lib/pkp/classes/db/DAOResultIterator.inc.php(33): DAOResultFactory->next()
#20 /var/www/journal/lib/pkp/classes/db/DAOResultFactory.inc.php(176): DAOResultIterator->__construct(Object(DAOResultFactory))
#21 /var/www/journal/lib/pkp/classes/services/PKPSubmissionService.inc.php(106): DAOResultFactory->toIterator()
#22 /var/www/journal/pages/issue/IssueHandler.inc.php(319): PKP\\Services\\PKPSubmissionService->getMany(Array)
#23 /var/www/journal/pages/index/IndexHandler.inc.php(62): IssueHandler::_setupIssueTemplate(Object(Request), Object(Issue))
#24 /var/www/journal/lib/pkp/classes/core/PKPRouter.inc.php(395): IndexHandler->index(Array, Object(Request))
#25 /var/www/journal/lib/pkp/classes/core/PKPPageRouter.inc.php(246):

Hi @the_reis

Glad to hear that you’re making progress. There is a locale column in a bunch of places, and it might have been added to a table during the initial schema synchronization that occurs when you upgrade. If you grep for “locale” in

dbscripts/xml/ojs_schema.xml

and in lib/pkp/xml/schema/*.xml

You’ll find it in a lot of places. To help narrow this down, you can enable debugging output in your config.inc.php file:

; Enable database debug output (very verbose!)
debug = Off

which should give you query it’s dying on.

Cheers,
Jason

Soooo… close… Found that the submissions.locale column was missing - added the column to the table and things look really good. But we were unable to edit an existing submission title. I added the locale by hand in the database for that submission and then was able to edit the submission in the UI.

Weird that the locales are missing - any suggestion if there’s any way to recover them from another table or reference, or are we looking at a manual process to re-add the locale to each submission?

Thanks so much for your help!

Hmmm, well, the locale for your submissions could be in a few possible places for reference. Is this a multilingual journal, generally? The locale on the submission is the one chosen by author when they submit, i.e. it’s the locale set in the journal’s Website Settings area, here:

locale

And if you’re only allowing one language, that’s the language that the submissions should have as a locale. If you allow more than one language, you could probably correlate right to the locale column in the publication_galleys table, which is the language the galley is in. The relationship to submissions would be via the submission_id column in the publications table, and then to the publication_galleys table via the publication_id column.

Cheers,
Jason

Yes, it’s a multilingual journal. I was able to correlate to locale in publication_galleys as you described. Thank you! I’ll start walking through some further tests to make sure things look all set.

Really appreciate your help!

1 Like