What are the Slack Archives?

Itโ€™s a history of our time together in the Slack Community! Thereโ€™s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you wonโ€™t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Error on Redis integration

U02P7B6K2LC
U02P7B6K2LC Posts: 121 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
edited June 2023 in Help

Hi Herdโ€ฆ
Trying to integrate Redis and getting this error:

Propel\Runtime\Exception\RuntimeException - Exception: No connection defined for database "zed". Did you forget to
define a connection or is it wrong written?
in /data/vendor/propel/propel/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php (303)

Got this while running step 5 in this: https://docs.spryker.com/docs/scos/dev/back-end-development/data-manipulation/data-pu[โ€ฆ]blishing/handling-data-with-publish-and-synchronization.html

Tagged:

Comments

  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    @valerii.trots Any idea on this one ?

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    is your database really called "zed"?

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    can you try to replace with name specified in deploy.yml file?

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 โœจ - Novice
    edited August 2022

    I would rather ask what version of spryker/console is used in the project? There was such kind of problem in the past.

  • U02P7B6K2LC
    U02P7B6K2LC Posts: 121 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    This Spryker was installed in December 2021

  • U02P7B6K2LC
    U02P7B6K2LC Posts: 121 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    The DB is called โ€œeu-dockerโ€ and the only mention of โ€œzedโ€ in our deploy file is for โ€œbackend_api_euโ€ application:

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 โœจ - Novice

    This Spryker was installed in December 2021

    Then it's something else. Not related to spryker/console.

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    I think i am also wrong, as i see that zed is also defined in other schema.xmls

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 โœจ - Novice

    I can find many occurrences of the same error message but majority related to running tests.
    There is a recent one not related to testing but without resolution. Asked the guy if he was able to find a cause.

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)
    edited August 2022

    can you check whether zed is defined in /config/Shared/config_propel.php

  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    edited August 2022

    so โ€˜zedโ€™ is configured in runtime connections, but database connections array is empty? should โ€˜zedโ€™ be added here also? just confused as to why it works to get data into zed database in the default redis implementations such as for products? and why this value would only need added now โ€ฆ

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    it might not be the root cause for your problem, but maybe you can compare this file with the stock demoshop one. Or is your shop a vanilla demo shop from Dec 2021?

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)
    <?php
    
    use Spryker\Shared\Propel\PropelConstants;
    use Spryker\Zed\Propel\PropelConfig;
    use Spryker\Zed\PropelOrm\Business\Builder\ExtensionObjectBuilder;
    use Spryker\Zed\PropelOrm\Business\Builder\ExtensionQueryBuilder;
    use Spryker\Zed\PropelOrm\Business\Builder\ObjectBuilder;
    use Spryker\Zed\PropelOrm\Business\Builder\QueryBuilder;
    
    $placeholder = '%s:host=%s;port=%d;dbname=%s';
    
    $dsn = sprintf(
        $placeholder,
        $config[PropelConstants::ZED_DB_ENGINE],
        $config[PropelConstants::ZED_DB_HOST],
        $config[PropelConstants::ZED_DB_PORT],
        $config[PropelConstants::ZED_DB_DATABASE]
    );
    
    $slaves = [];
    foreach ($config[PropelConstants::ZED_DB_REPLICAS] ?? [] as $slaveData) {
        $slaves[] = [
            'dsn' => sprintf(
                $placeholder,
                $config[PropelConstants::ZED_DB_ENGINE],
                $slaveData[PropelConstants::ZED_DB_HOST],
                $slaveData[PropelConstants::ZED_DB_PORT],
                $config[PropelConstants::ZED_DB_DATABASE]
            ),
            'user' => $config[PropelConstants::ZED_DB_USERNAME],
            'password' => $config[PropelConstants::ZED_DB_PASSWORD],
        ];
    }
    
    $connections = [
        'pgsql' => [
            'adapter' => PropelConfig::DB_ENGINE_PGSQL,
            'dsn' => $dsn,
            'user' => $config[PropelConstants::ZED_DB_USERNAME],
            'password' => $config[PropelConstants::ZED_DB_PASSWORD],
            'slaves' => $slaves,
            'settings' => [],
        ],
        'mysql' => [
            'adapter' => PropelConfig::DB_ENGINE_MYSQL,
            'dsn' => $dsn,
            'user' => $config[PropelConstants::ZED_DB_USERNAME],
            'password' => $config[PropelConstants::ZED_DB_PASSWORD],
            'slaves' => $slaves,
            'settings' => [
                'charset' => 'utf8',
                'queries' => [
                    'utf8' => 'SET NAMES utf8 COLLATE utf8_unicode_ci, COLLATION_CONNECTION = utf8_unicode_ci, COLLATION_DATABASE = utf8_unicode_ci, COLLATION_SERVER = utf8_unicode_ci',
                ],
            ],
        ],
    ];
    
    $config[PropelConstants::PROPEL] = [
        'database' => [
            'connections' => [],
        ],
        'runtime' => [
            'defaultConnection' => 'default',
            'connections' => ['default', 'zed'],
        ],
        'generator' => [
            'defaultConnection' => 'default',
            'connections' => ['default', 'zed'],
            'objectModel' => [
                'defaultKeyType' => 'fieldName',
                'builders' => [
                    // If you need full entity logging on Create/Update/Delete, then switch to
                    // Spryker\Zed\PropelOrm\Business\Builder\ObjectBuilderWithLogger instead.
                    'object' => ObjectBuilder::class,
                    'objectstub' => ExtensionObjectBuilder::class,
                    'query' => QueryBuilder::class,
                    'querystub' => ExtensionQueryBuilder::class,
                ],
            ],
        ],
        'paths' => [
            'phpDir' => APPLICATION_ROOT_DIR,
            'sqlDir' => APPLICATION_ROOT_DIR . '/src/Orm/Propel/Sql',
            'migrationDir' => APPLICATION_ROOT_DIR . '/src/Orm/Propel/Migration_' . $config[PropelConstants::ZED_DB_ENGINE],
            'schemaDir' => APPLICATION_ROOT_DIR . '/src/Orm/Propel/Schema',
            'loaderScriptDir' => APPLICATION_ROOT_DIR . '/src/Orm/Propel/generated-conf/',
        ],
    ];
    
    $ENGINE = $config[PropelConstants::ZED_DB_ENGINE];
    $config[PropelConstants::PROPEL]['database']['connections']['default'] = $connections[$ENGINE];
    $config[PropelConstants::PROPEL]['database']['connections']['zed'] = $connections[$ENGINE];
    
  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    yes it is a standard B2C demo shop

  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    yea it seems that is very similar to our implementation, also the database connections array is empty there also so seems that may not be the issue

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    If this is not urgent, we can take a closer look on this docu next week and come back to you

  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    yea sure any help whenever you guys get time would be appreciated, thank you Thomas ๐Ÿ™‚

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    Sure thing, have a good weekend

  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Any updates found on this @U02U16B54Q7? Is there any member of your team thatโ€™d have specific knowledge on docs sections and what they mean, e.g.

  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    what it means here by run the controller ? like how do we do this ?

  • U02P7B6K2LC
    U02P7B6K2LC Posts: 121 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    edited August 2022

    Hey just to clarifyโ€ฆ weโ€™re on step 5 of this: https://docs.spryker.com/docs/scos/dev/back-end-development/data-manipulation/data-pu[โ€ฆ]blishing/handling-data-with-publish-and-synchronization.html

    The step is to: โ€œ*Create a controller class as follows and run it.*โ€

    We donโ€™t know how to โ€œrun itโ€ โ€ฆ since weโ€™re not using Yves then we canโ€™t simply โ€œrun itโ€ โ€ฆ so we decided to hook up a Glue API endpoint to try to run it and thatโ€™s where we get the โ€œzedโ€ error.

    My guess is, that since weโ€™re in Glue, thereโ€™s no direct access to ZED.

    If we back up a littleโ€ฆ is there any way to โ€œrunโ€ a ZED module here without Yves? Or is there something weโ€™re missing when trying to run a ZED module from Glue?

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    Hey Ray, i have asked one of our team to investigate and share results

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    And your explanation sounds reasonable

  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    cool thanks Thomas !

  • Thomas Lehner
    Thomas Lehner Support Engineer @ Spryker Posts: 289 ๐Ÿ› - Council (mod)

    While this is going on, can you please share a description of your use case? Like what are you building here and for what purpose? Makes it easier to check

  • U03H06V0LAY
    U03H06V0LAY Posts: 39 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    edited August 2022

    weโ€™re building our own custom Recipe module, so in this case recipe storage, weโ€™re trying to get the recipes into Redis, already have them in Elasticsearch and MariaDB

  • U02P7B6K2LC
    U02P7B6K2LC Posts: 121 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    We built the original module using the info from the intermediate course on the Spryker Academy. One of the tasks is to build the ES side โ€ฆ weโ€™re now trying to build the Redis side of the same module.