Skip to content

Race condition in SCSS generation #5395

Description

@MorrisJobke
  • update the Nextcloud to a new version (this one was from an update of stable12 from 1 week ago to todays version)
  • open the files app in parallel in multiple browsers (at least I think this is the reason)
  • see following exception:
Doctrine\DBAL\Exception\UniqueConstraintViolationException

An exception occurred while executing 'INSERT INTO `oc_filecache` (`etag`,`mimepart`,`mimetype`,`size`,`mtime`,`storage_mtime`,`permissions`,`path_hash`,`path`,`parent`,`name`,`storage`) SELECT ?,?,?,?,?,?,?,?,?,?,?,? FROM `oc_filecache` WHERE `storage` = ? AND `path_hash` = ? HAVING COUNT(*) = 0' with params ["59404b2c2b8e3", "37", "65", 0, 1497385772, 1497385772, 27, "8799a3a675f3b20bed7cf48c10c9cc7d", "appdata_occklwda4mqc\/css\/core\/server.css", 277, "server.css", 9, 9, "8799a3a675f3b20bed7cf48c10c9cc7d"]:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '9-8799a3a675f3b20bed7cf48c10c9cc7d' for key 'fs_storage_path_hash'
#0 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(128): Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))
#1 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1015): Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Driver\PDOException), 'INSERT INTO `oc...', Array)
#2 lib/private/DB/Connection.php(213): Doctrine\DBAL\Connection->executeUpdate('INSERT INTO `oc...', Array, Array)
#3 lib/private/DB/Adapter.php(114): OC\DB\Connection->executeUpdate('INSERT INTO `oc...', Array)
#4 lib/private/DB/Connection.php(251): OC\DB\Adapter->insertIfNotExist('*PREFIX*filecac...', Array, Array)
#5 lib/private/Files/Cache/Cache.php(273): OC\DB\Connection->insertIfNotExist('*PREFIX*filecac...', Array, Array)
#6 lib/private/Files/Cache/Cache.php(230): OC\Files\Cache\Cache->insert('appdata_occklwd...', Array)
#7 lib/private/Files/ObjectStore/ObjectStoreStorage.php(354): OC\Files\Cache\Cache->put('appdata_occklwd...', Array)
#8 lib/private/Files/Storage/Wrapper/Wrapper.php(349): OC\Files\ObjectStore\ObjectStoreStorage->touch('appdata_occklwd...', 1497385772)
#9 lib/private/Files/Storage/Wrapper/Availability.php(373): OC\Files\Storage\Wrapper\Wrapper->touch('appdata_occklwd...', NULL)
#10 lib/private/Files/Storage/Wrapper/Wrapper.php(349): OC\Files\Storage\Wrapper\Availability->touch('appdata_occklwd...', NULL)
#11 lib/private/Files/View.php(1132): OC\Files\Storage\Wrapper\Wrapper->touch('appdata_occklwd...')
#12 lib/private/Files/View.php(559): OC\Files\View->basicOperation('touch', '/appdata_occklw...', Array, NULL)
#13 lib/private/Files/Node/Folder.php(181): OC\Files\View->touch('/appdata_occklw...')
#14 lib/private/Files/SimpleFS/SimpleFolder.php(83): OC\Files\Node\Folder->newFile('server.css')
#15 lib/private/Template/SCSSCacher.php(198): OC\Files\SimpleFS\SimpleFolder->newFile('server.css')
#16 lib/private/Template/SCSSCacher.php(112): OC\Template\SCSSCacher->cache('/var/www/nextcl...', 'server.css', 'server.scss', Object(OC\Files\SimpleFS\SimpleFolder), 'core/css')
#17 lib/private/Template/CSSResourceLocator.php(99): OC\Template\SCSSCacher->process('/var/www/nextcl...', 'core/css/server...', 'core')
#18 lib/private/Template/CSSResourceLocator.php(56): OC\Template\CSSResourceLocator->cacheAndAppendScssIfExist('/var/www/nextcl...', 'core/css/server...')
#19 lib/private/Template/ResourceLocator.php(75): OC\Template\CSSResourceLocator->doFind('css/server')
#20 lib/private/TemplateLayout.php(225): OC\Template\ResourceLocator->find(Array)
#21 lib/private/TemplateLayout.php(170): OC\TemplateLayout::findStylesheetFiles(Array)
#22 lib/private/legacy/template.php(205): OC\TemplateLayout->__construct('user', 'files')
#23 lib/public/AppFramework/Http/TemplateResponse.php(157): OC_Template->fetchPage()
#24 lib/private/AppFramework/Http/Dispatcher.php(113): OCP\AppFramework\Http\TemplateResponse->render()
#25 lib/private/AppFramework/App.php(114): OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Files\Controller\ViewController), 'index')
#26 lib/private/AppFramework/Routing/RouteActionHandler.php(47): OC\AppFramework\App::main('ViewController', 'index', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
#27 [internal function]: OC\AppFramework\Routing\RouteActionHandler->__invoke(Array)
#28 lib/private/Route/Router.php(299): call_user_func(Object(OC\AppFramework\Routing\RouteActionHandler), Array)
#29 lib/base.php(1003): OC\Route\Router->match('/apps/files/')
#30 index.php(40): OC::handleRequest()
#31 {main}

File:3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
Line:66
version:12.0.0.29

@rullzer @nickvergessen @icewind1991 @skjnldsv @juliushaertl I guess we need a locking around the asset caching to prevent that the SCSS is compiled twice and then it tries to write it twice causing that exception, or am I wrong here?

Activity

  1. skjnldsv commented on Jun 14, 2017

    @skjnldsv
    Member

    Is it really related to the scss part of core? Maybe see into the cache system first?
    Iirc we're using core's cache public function in the scss generation? :)

  2. nickvergessen commented on Jun 14, 2017

    @nickvergessen
    Member

    Sounds like wrong transaction isolation level

  3. rullzer commented on Jul 21, 2017

    @rullzer
    Member

    Probabaly because locking doesn't work there... @icewind1991

  4. MorrisJobke commented on Nov 14, 2017

    @MorrisJobke
    MemberAuthor

    Never experienced it again. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions