Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to write to metaData #36

Open
davidbiga opened this issue Aug 22, 2020 · 8 comments
Open

Unable to write to metaData #36

davidbiga opened this issue Aug 22, 2020 · 8 comments

Comments

@davidbiga
Copy link

Hello,

I've built this project around Docker and have configured the right dependencies, project, but when I run a request to login, I keep getting an error exception thrown the MetaData class.

Here is the exact error:

<br />
<b>Fatal error</b>:  Uncaught Phalcon\Mvc\Model\Exception: Failed to store metaData to the cache adapter in /api/library/Traits/QueryTrait.php:139
Stack trace:
#0 [internal function]: Phalcon\Mvc\Model\MetaData-&gt;throwWriteException(true)
#1 [internal function]: Phalcon\Mvc\Model\MetaData-&gt;write('map-phalcon\\api...', Array)
#2 [internal function]: Phalcon\Mvc\Model\MetaData-&gt;initialize(Object(Phalcon\Api\Models\Users), NULL, NULL, NULL)
#3 [internal function]: Phalcon\Mvc\Model\MetaData-&gt;readColumnMapIndex(Object(Phalcon\Api\Models\Users), 1)
#4 [internal function]: Phalcon\Mvc\Model\MetaData-&gt;getReverseColumnMap(Object(Phalcon\Api\Models\Users))
#5 [internal function]: Phalcon\Mvc\Model\MetaData-&gt;hasAttribute(Object(Phalcon\Api\Models\Users), 'username')
#6 [internal function]: Phalcon\Mvc\Model\Query-&gt;_getQualified(Array)
#7 [internal function]: Phalcon\Mvc\Model\Query-&gt;_getExpression(Array, true)
#8 [internal function]: Phalcon\Mvc\Model\Query-&gt;_getExpression(Array, true)
#9 [internal function]: Phalcon\Mvc\Model\Query-&gt;_getEx in <b>/api/library/Traits/QueryTrait.php</b> on line <b>139</b><br />

I did make sure that memcached was installed and also running on my machine. Permissions seem to be correct on the folders as it is able to write logs within the storage directory.

Do you have any suggestions?

@xaero7
Copy link

xaero7 commented Aug 24, 2020

@davidbiga Hi,Did you have any idea (or demostration) of pagination?

@davidbiga
Copy link
Author

@xaero7 @jenovateurs this is not about pagination. This when when the API is preparing the sql query to execute and store the models MetaData into cache.

Phalcon Version: 4.0.5
Phalcon DevTools Version: 4.0.0
PHP Version: 7.4.9

@jenovateurs
Copy link

@davidbiga Did you try to comment memcached service and make a simple request to the database. Just to verify that the connection between the API and database works.

@davidbiga
Copy link
Author

davidbiga commented Aug 24, 2020

@jenovateurs You're referring to commenting out:

$container->setShared(
            'modelsMetadata',
            function () {
                $backOptions = [
                    'servers'  => [
                        0 => [
                            'host'   => envValue('DATA_API_MEMCACHED_HOST', '127.0.0.1'),
                            'port'   => envValue('DATA_API_MEMCACHED_PORT', 11211),
                            'weight' => envValue('DATA_API_MEMCACHED_WEIGHT', 100),
                        ],
                    ],
                    'client'   => [
                        \Memcached::OPT_PREFIX_KEY => 'api-',
                    ],
                    'lifetime' => 3600,
                    'prefix'   => 'metadata-',
                ];

                $serializer = new SerializerFactory();
                $adapterFactor = new AdapterFactory($serializer);

                return new Libmemcached($adapterFactor, $backOptions);
            }
        );

inside ModelsMetadataProvider? Also per the Exception thrown, shouldn't a "can't connect to db" be thrown prior?

@jenovateurs
Copy link

@davidbiga yes can you comment this block of your code. Just to check if there isn't another error.

@davidbiga
Copy link
Author

davidbiga commented Aug 24, 2020

@jenovateurs I disabled modelsMetadata, had to fix a DB connection issue and logged in request went through with a 200. After I re-enabled modelsMetadata, I was met with the same error message.

@jenovateurs
Copy link

jenovateurs commented Aug 25, 2020

@davidbiga I think it's a Phalcon issue and not a problem related to this rest-api project. Could you transfer/write this issue in the Phalcon project ? https://github.com/phalcon/cphalcon/issues
I think you will get more answers to your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants