0
votes

When I run my query function to datastore emulator, it just starts executing and doesn't stop. No errors are thrown, no nothing. CPU is heavily loaded until I just kill the job. I did set the environment variables, I even manually provided apiEndpoint to my query function

const datastore = new Datastore({
        apiEndpoint: "http://localhost:8081"
    });

Output from SDK is as follows:

Executing: cmd /c C:\Users\oskid\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\cloud-datastore-emulator\cloud_datastore_emulator.cmd start --host=localhost --port=8081 --store_on_disk=True --consistency=0.9 --allow_remote_shutdown C:\Users\oskid\AppData\Roaming\gcloud\emulators\datastore [datastore] Mar 18, 2020 9:47:38 AM com.google.cloud.datastore.emulator.CloudDatastore$FakeDatastoreAction$9 apply [datastore] INFO: Provided --allow_remote_shutdown to start command which is no longer necessary. [datastore] Mar 18, 2020 9:47:38 AM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub [datastore] INFO: Local Datastore initialized: [datastore]
Type: High Replication [datastore] Storage: C:\Users\oskid\AppData\Roaming\gcloud\emulators\datastore\WEB-INF\appengine-generated\local_db.bin [datastore] Mar 18, 2020 9:47:39 AM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub load [datastore] INFO: The backing store, C:\Users\oskid\AppData\Roaming\gcloud\emulators\datastore\WEB-INF\appengine-generated\local_db.bin, does not exist. It will be created. [datastore] API endpoint: http://localhost:8081 [datastore] If you are using a library that supports the DATASTORE_EMULATOR_HOST environment variable, run: [datastore] [datastore] export DATASTORE_EMULATOR_HOST=localhost:8081 [datastore] [datastore] Dev App Server is now running. [datastore] [datastore] The previous line was printed for backwards compatibility only. [datastore] If your tests rely on it to confirm emulator startup, [datastore] please migrate to the emulator health check endpoint (/). Thank you! [datastore] The health check endpoint for this emulator instance is http://localhost:8081/Mar 18, 2020 9:54:25 AM io.gapi.emulators.grpc.GrpcServer$3 operationComplete [datastore] INFO: Adding handler(s) to newly registered Channel. [datastore] Mar 18, 2020 9:54:25 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead [datastore] INFO: Detected HTTP/2 connection.

End output from my query function:

C:\Users\oskid\Desktop\my_project\cloud-functions\queryDS>npm start

[email protected] start C:\Users\oskid\Desktop\my_project\cloud-functions\queryDS functions-framework --target=staging_queryDS --port=443

Serving function... Function: staging_queryDS URL: http://localhost:443/ Supported severity levels: debug, info, notice, warning, error, critical, alert, emergency [notice] in [staging undefined queryDS] {"labels":{"appInstance":"staging","scope":"queryDS"}} : {"message":"[staging undefined queryDS] Invocation of function started"}

Nothing gets generated in datastore\WEB-INF\appengine-generated folder, and no indexes are added to the local index.yaml. Any ideas how to troubleshoot this?

1

1 Answers

0
votes

The first step would be to make sure that the Datastore Emulator component of the Cloud SDK is updated. This can be done via “gcloud components update”, and is referenced here. In order to make sure that the Cloud Function can execute properly, please run a test with a very simple query which is guaranteed to return successful results quickly as far as the database is concerned. If it does, then it is advised to review the query submitted to target inefficiencies and make sure it follows best practices, detailed here. If it does not, you may look into the Cloud Function logs to see which operation fails.