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.