[SOLVED] Database error on local copy

Hi,

I tried to replicate my production neos instance on my local machine. I set everything up, exported the database and imported it locally. I rsynced the Data/Persistent/Resources directory to my local machine.
Everything worked. No errors/exceptions (neither rsync nor mysql).

If I try to visit the local pages, I can access only some. The other yield me a 500 internal server error.

The error:

An exception occurred while executing 'INSERT INTO neos_flow_resourcemanagement_persistentresource (persistence_object_identifier, collectionname, filename, filesize, relativepublicationpath, mediatype, sha1) VALUES (?, ?, ?, ?, ?, ?, ?)' with params ["798f3254-b2e1-47a5-a3a2-e8c30f04b3d5", "persistent", "99-finished-oak-floor-lamp-1920x1280.jpg", 312715, "", "image\/jpeg", "b811113df2d02f9b8928f48a59e8c759b0c040f9"]:
SQLSTATE[HY000]: General error: 1364 Field 'md5' doesn't have a default value

Exception Code	0
Exception Type	Doctrine\DBAL\Exception\NotNullConstraintViolationException
Thrown in File	Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
Line	125

Nested Exception
SQLSTATE[HY000]: General error: 1364 Field 'md5' doesn't have a default value
Exception Code	HY000
Exception Type	Doctrine\DBAL\Driver\PDO\Exception
Thrown in File	Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php
Line	18

Nested Exception
SQLSTATE[HY000]: General error: 1364 Field 'md5' doesn't have a default value
Exception Code	HY000
Exception Type	PDOException
Thrown in File	Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
Line	117

PDOStatement::execute()
Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
00115:     {
00116:         try {
00117:             return parent::execute($params);
00118:         } catch (PDOException $exception) {
00119:             throw Exception::new($exception);
Doctrine\DBAL\Driver\PDOStatement::execute()
Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Statement.php
00177: 
00178:         try {
00179:             $stmt = $this->stmt->execute($params);
00180:         } catch (Throwable $ex) {
00181:             if ($logger) {
[…] 
Packages/Framework/Neos.Flow/Classes/Core/Bootstrap.php
00110: 
00111:         $this->activeRequestHandler = $this->resolveRequestHandler();
00112:         $this->activeRequestHandler->handleRequest();
00113:     }
00114: 
Neos\Flow\Core\Bootstrap::run()
Web/index.php
00025: $context = \Neos\Flow\Core\Bootstrap::getEnvironmentConfigurationSetting('FLOW_CONTEXT') ?: 'Development';
00026: $bootstrap = new \Neos\Flow\Core\Bootstrap($context, $composerAutoloader);
00027: $bootstrap->run();

Instance root	/var/www/oevre-development/
Application Context	Development
Request Handler	Neos\Flow\Http\RequestHandler

On the sites that work, only some images are loaded. Others return a 404.
Therefore, I tried to create/import the resources.

I found that something is odd with the images.

./flow resource:publish
Publishing resources of collection "static"
Publishing resources of collection "persistent"

The resources were published, but a few inconsistencies were detected. You can check and probably fix the integrity of the resource registry by using the resource:clean command.
Error: Could not publish resource unsplash_5-480x320.jpg with SHA1 hash 27638e65340418b2efb0d6c70190b8b970e69475 of collection persistent because there seems to be no corresponding data in the storage.
(for 8 different images)

I find this error strange, because I rsynced the whole resources directory. I have no problems with the production instance. All images are present and work.

I thought, that maybe not all thumbnails got created and i ran:

./flow media:renderthumbnails
    0/6743 [>---------------------------]   0%

An exception occurred while executing 'INSERT INTO neos_flow_resourcemanagement_persistentresource (persistence_object_identifier, collectionname, filename, filesize, relativepublicationpath, mediatype, sha1) VALUES (?, ?, ?, ?, ?, ?, ?)' with params ["b58dee32-d13d-4461-a5d5-750c0ee64cbe", "persistent", "40-sitting-on-the-dock-945x630.jpg", 83048, "", "image\/jpeg", "50146bb81c192698ca0226ed277796957bfcf884"]:
SQLSTATE[HY000]: General error: 1364 Field 'md5' doesn't have a default
value

  Type: Doctrine\DBAL\Exception\NotNullConstraintViolationException
  File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriv
        er.php
  Line: 125

Nested exception:
SQLSTATE[HY000]: General error: 1364 Field 'md5' doesn't have a default value

  Type: Doctrine\DBAL\Driver\PDO\Exception
  Code: HY000
  File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php
  Line: 18

Nested exception:
SQLSTATE[HY000]: General error: 1364 Field 'md5' doesn't have a default value

  Type: PDOException
  Code: HY000
  File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
  Line: 117

Which is the same error as above. So, the loading of the pages fail because the generation of thumbnails throws an exception for some reason.

How can I debug this?


Neos.ContentRepository                             7.2.0          
Neos.Flow                                          7.2.1          
Neos.FluidAdaptor                                  7.2.1          
Neos.Fusion                                        7.2.0          
Neos.Fusion.Afx                                    7.2.0          
Neos.Http.Factories                                7.2.1          
Neos.Imagine                                       3.2.0          
Neos.Media                                         7.2.0          
Neos.Media.Browser                                 7.2.0          
 Neos.Neos                                          7.2.0

This was solved in slack and was due to a mismatch in database schemas.

So how was it solved? What should someone else do, if they encounter the same issue in the future? :slight_smile:

1 Like

Mismatch in database schemas as written, to avoid it, make sure you actually copy the full db schema and also import to an empty DB.

This is the valuable part of information, that hopefully helps the next one :star_struck:

It was way simpler, actually (and embarrassingly). I hadn’t run the migration for 7.2, although I thought I had…