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

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:

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Posts: 39 πŸ§‘πŸ»β€πŸš€ - Cadet

    @valerii.trots Any idea on this one ?

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

    is your database really called "zed"?

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

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

  • 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.

  • Posts: 121 πŸ§‘πŸ»β€πŸš€ - Cadet

    This Spryker was installed in December 2021

  • 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:

  • SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    This Spryker was installed in December 2021

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

  • 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

  • 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.

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

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

  • 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 …

  • 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?

  • 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];
    
  • Posts: 39 πŸ§‘πŸ»β€πŸš€ - Cadet

    yes it is a standard B2C demo shop

  • 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

  • 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

  • Posts: 39 πŸ§‘πŸ»β€πŸš€ - Cadet

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

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

    Sure thing, have a good weekend

  • 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.

  • Posts: 39 πŸ§‘πŸ»β€πŸš€ - Cadet

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

  • 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?

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

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

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

    And your explanation sounds reasonable

  • Posts: 39 πŸ§‘πŸ»β€πŸš€ - Cadet

    cool thanks Thomas !

  • 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

  • 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

  • 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.

Welcome!

It looks like you're new here. Sign in or register to get started.