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

Cloud Spanner throw Auth error:Error: read ECONNRESET intermittently #118

Closed
manasi99 opened this issue Feb 9, 2018 · 8 comments
Closed
Assignees
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@manasi99
Copy link

manasi99 commented Feb 9, 2018

I have a cloud function deployed on GCP which is triggered by Cloud Pub/Sub topic. It connects to cloud spanner to insert the pub/sub event data. It is a high volume pub/sub topic and make simultaneous insert requests in different cloud spanner table. However, it keep giving below errors intermittently. Application Default Credentials are used to do authentication of Cloud Spanner.

ERROR: { Error: Getting metadata from plugin failed with error: read ECONNRESET at /user_code/node_modules/@google-cloud/spanner/node_modules/grpc/src/client.js:554:15 code: 16, metadata: Metadata { _internal_repr: {} }, note: 'Exception occurred in retry method that was not classified as transient' }

Below are the dependencies in package.json

 "dependencies": {
      "safe-buffer": "5.1.1",
      "@google-cloud/spanner": "1.0.3",
      "google-gax": "^0.14.5"
}

Environment details

  • Node.js version: v8.5.0
  • npm version: 5.3.0
  • @google-cloud/spanner version: 1.0.3
@stephenplusplus
Copy link
Contributor

It sounds like you might need to write some retry logic around the code that's causing problems. But to be sure there's not anything we can do, can you show the code that calls the method which is returning the error?

@stephenplusplus stephenplusplus added type: question Request for information or clarification. Not an issue. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Feb 9, 2018
@vkedia
Copy link
Contributor

vkedia commented Feb 9, 2018

But this does not look like an error that users should be seeing. We do not want users to be retrying operations. If the error is retryable, then the library should retry it.

@callmehiphop
Copy link
Contributor

@manasi99 could you put together a minimal amount of code that reproduces this issue for us? That should help us resolve this issue for you quickly.

@manasi99
Copy link
Author

manasi99 commented Feb 9, 2018

@stephenplusplus @callmehiphop : This is the simple version of actual code where the error is caught in catch block:

const Spanner = require('@google-cloud/spanner');
const config = require('./config.js');

const spannerClient = new Spanner({
	projectId: config.PROJECT_ID
});

const spannerInstance = spannerClient.instance(config.INSTANCE_ID);

const spannerDatabase = spannerInstance.database(config.DATABASE_ID);

exports.upsertRows = function(tableName, rows) {
return new Promise((resolve, reject) => {
	try {
		const spannerTable = spannerDatabase.table(tableName);
		spannerTable.upsert(rows)
			.then(() => {
				console.log('Upserted data.');
				resolve(true);
			})
			.catch(err => {
				console.error(`Upsert `, err);
				reject(err);
			});
		});
	} catch (err) {
		console.error(`upsertRows `, err);
		reject(err);
	}
};

@stephenplusplus
Copy link
Contributor

This has been addressed by a dependency, google-auth-library: googleapis/google-auth-library-nodejs#283. It won't be pulled in automatically, however, we are still determining our game plan to get it out (stephenplusplus/google-auto-auth#39).

I'll mark this as blocked, but hopefully not for long.

@stephenplusplus stephenplusplus added status: blocked Resolving the issue is dependent on other work. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed type: question Request for information or clarification. Not an issue. labels Feb 20, 2018
@pembeci
Copy link

pembeci commented Feb 22, 2018

We are also seeing these "Auth error:Error: read ECONNRESET" errors in our Cloud Function environment which utilizes Spanner. Since our setup is too complex we were running different narrowed down versions of our code and trying this patch to understand if it is caused by something on our part or a more general Cloud issue. Now that we noticed this issue, at least let me show some of our logs. All of the below logs belong to the same function execution_id but we have a similar pattern in many other calls:

10:20:48.771 Function execution started
10:20:48.875 {... "runId":"SygFY--vIM", "respCode":200, "ALL":98....}
10:20:48.875 Function execution took 104 ms, finished with status code: 200
11:10:28.435 Auth error:Error: read ECONNRESET
11:10:28.734 Auth error:Error: read ECONNRESET
11:10:28.834 Auth error:Error: read ECONNRESET
11:10:28.834 Auth error:Error: read ECONNRESET
11:10:28.934 Auth error:Error: read ECONNRESET
11:10:35.635 Auth error:Error: read ECONNRESET
11:10:35.636 Auth error:Error: read ECONNRESET
11:10:39.034 Unhandled rejection
11:10:39.134 Error: Getting metadata from plugin failed with error: read ECONNRESET
    at /user_code/node_modules/grpc/src/client.js:554:15
11:10:42.035 [runId: S1SwZWv8M] Unhandled promise rejection: 'Error: Getting metadata from plugin failed with error: read ECONNRESET'

What is interesting is that we are getting these Auth errors 50 minutes after the original request is already completed successfully. Although console.log reports them with the same function execution_id, our own corresponding runId (on 2nd and last logs) shows that the error was logged while another request was handled. @stephenplusplus, do you think we have the same issue discussed here or shall we continue digging in our code? Thanks.

@stephenplusplus
Copy link
Contributor

This should be resolved now, as we have upgraded to the latest google-auth-library via google-auto-auth. To pull in the changes, just un- and re-install @google-cloud/spanner. Please let me know if the problem persists, and we will re-investigate.

@ghost ghost removed the priority: p2 Moderately-important priority. Fix may not be included in next release. label Mar 8, 2018
@stephenplusplus stephenplusplus removed the status: blocked Resolving the issue is dependent on other work. label Mar 8, 2018
@pembeci
Copy link

pembeci commented Mar 8, 2018

Thanks. We'll test it immediately.

@google-cloud-label-sync google-cloud-label-sync bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Jan 31, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

6 participants