Google App Engine - connect debugger on production - google-app-engine

I have a production issue with a GAE application. The problem seems to be related only to some users.
Is there a possibility to connect the local debugger to the prod version ? I'd like to avoid to have to copy the prod data to the dev server.
Thanks !

This situation has improved as of a few days ago with the intoduction of Google Cloud Debugger
Earlier this week at Google Cloud Platform Live, we launched the beta release of Cloud Debugger which makes it easier to troubleshoot applications in production. Now you can simply pick a line of code, set a watchpoint and the debugger will return local variables and a full stack trace from the next request that executes that line on any replica of your service. There is zero setup time, no complex configurations and no performance impact noticeable to your users.
Here's the blog post
Here's the info

Not possible, you can only debug using the logs.

I managed to solve the issue. The problem was that one program was throwing an exception and I did not catch it properly. The code was
catch (Exception e) {
e.printStackTrace();
}
On the development platform the exception was thrown at the console. The problem in production is that it does not appear in the GAE console. This has two very bad outcomes :
--> 1) The end user does not know that the transaction did not end successfully
--> 2) The administrator has no clue that a problem has occurred and no way to debug
==>
I have therefore replaced the code by
catch (Exception e) {
final Logger log = Logger.getLogger(InternalServiceImpl.class.getName());
log.severe("Problem while updating XXX record : " + e.getLocalizedMessage());
updatedRecord.setRPCResult(DB_PROBLEM); // This is specific to my application to notify the end user
}
I did modify the code relaunched the application and found out that the problem was a resource contention in a transaction.
Was really a stupid beginner mistake.

Related

Google App Engine: FileServiceImpl.translateException on closeFinally()

This may be related to Google File Service closeFinally() timeout.
My Java GAE app is running on SDK 1.8.2 and is hitting a translateException when calling closeFinally() on a FileWriteChannel. I'll be updating the SDK and migrating to the new Cloud Storage API but need to resolve this exception asap for a customer so am wondering if anyone has some insight into the issue for a quick fix.
Here's a simplification of the code that's causing the issue:
AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build());
String gcsWritePath = writableFile.getFullPath();
FileWriteChannel writeChannel = fileService.openWriteChannel(writableFile, true);
for(conditions) {
Do stuff and write to gcsWritePath
if(recordsWritten > threshold) {
Kick off new task with a startAtparam to avoid OOM and timeouts
break;
}
}
if(all records written) {
writeChannel.closeFinally(); // Exception happens here
}
And the exception details
java.io.IOException
at com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImpl.java:621)
at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:594)
at com.google.appengine.api.files.FileServiceImpl.close(FileServiceImpl.java:565)
at com.google.appengine.api.files.FileServiceImpl.close(FileServiceImpl.java:457)
at com.google.appengine.api.files.FileWriteChannelImpl.closeFinally(FileWriteChannelImpl.java:97)
The exception only appears to occur for longer running tasks (e.g. 5+ minutes) so it looks like this might be a timeout. I've tried adjusting the threshold without much luck though. I also tried looking through the app engine sdk source for FileServiceImpl.java and ApiProxy.java but didn't find any good clues.
Does anyone have any ideas as to what might be causing this?

Cloud Integration: An error occurred when creating the project. Please retry

I created a new GAE app, but the Cloud Integration section on the Settings page tells me that "An error occurred when creating the project. Please retry."
I have pressed the Retry button multiple times over a period of many hours, but it's just not working. I found this thread, which repeatedly says that the issue is solved, but it's not resolved for me.
Is anyone from Google monitoring this forum? Can you help?
The only solution seems to be to create a new app, and hope for the best (it worked for me). Sadly, if you delete the problem app, the app-id is lost forever.
This is a bit late, but in case someone else stumbles on this question.
In the google cloud console, activate billing from the Storage>Cloud Storage > Browser tab, then activate / retry under Cloud Integration from appengine.google.com.
I didn't need to create a new app id, when I went that route.

Having issues getting WordPress running under GAE + Cloud SQL

I tried to set up WordPress under Google App Engine earlier tonight (following the instructions here: https://developers.google.com/appengine/articles/wordpress).
It runs fine locally, but when I push to remote I get a database error (visible at https://wp-dot-frontiermediag.appspot.com/). If we throw on a /wp_admin/install.php you get:
This either means that the username and password information in your
wp-config.php file is incorrect or we can't contact the database server
at :/cloudsql/frontiermediag:fmwp. This could mean your host's database
server is down.
Here's the relevant code in wp-config:
/** MySQL hostname */
if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
define('DB_HOST', ':/cloudsql/frontiermediag:fmwp');
}else{
define('DB_HOST', 'localhost');
}
frontiermediag:fmwp is showing "Status Runnable" in Developers Console > Cloud SQL.
I did this once before and it worked so I'm not sure what I'm missing here. I thought it might have been because I'm using WP 3.8.1. but rolled back to 3.5.1 and same thing's happening.
Any ideas? frontiermediag is listed as an authorized application on the :fmwp ACL.
This situation happened to me earlier.However, I edited my Cloud SQL instance , and set "Preferred Location" as "Follow App Engine App" from Google Developers Console. This database connection problem was solved in my case.
I tried the instructions with wordpress 3.5.1 and the instructions seem to work for me. The code snippet you have above seems right and I am not sure what could be wrong without looking at rest of your code. Can you try the instructions from the beginning one more time with 3.5.1?
I had this issue, because "Follow App Engine App" doesn't seem to be an option for second generation instances in my case, and so the instance connection name includes the region setting.
Look at the instance details, and under properties, find "Instance connection name". That is the text that should follow :cloudsql/.

Google App Engine could not upload the project file

I made a change to backends.py and I'm trying to upload the project and am getting an error. I have used the rollback command as well but I keep getting the error.
Error 409: --- begin server output ---
Another transaction by user admin is already in progress for app: s~test-appx,
backend: urlstat. That user can undo the transaction with "appcfg backends rollback".
--- end server output ---
Does anyone have any idea about this?
This happens on occasion when something terrible happens during a push. If you wait long enough, it will eventually time out and you will be able to update normally again.
The lock is specific to a version of your application. So, if time is short, you can work around this error by pushing to a different version, and then making it the default from the appspot.com dashboard.
The -V flag allows you to specify which version to target.
appcfg.py -V 2 update ./myapp
I had the same error on an "interrupted" update and yes the rollback doesn't help either. What worked for me was to keep updating until the error went away - this isn't a real answer but I don't seem to be able to add comments

How do I display an exception's full stacktrace in Google App Engine's app log?

While detaching an object from the datastore in a deployed app on Google App Engine, I'm getting an "failed to detach" exception that I can't reproduce on my development box. The detach operation is server-side, so the only information I have on it is the log of the exception in the app's log files. However, the stacktrace is elided: for example, the deepest internal exception ends with "... 36 more".
How do I adjust the verbosity of the app's logging to include the full, non-elided stacktrace?
What you can do is to add the Throwable as a parameter when logging an exception. ie:
Logger log = Logger.getLogger(YourClass.class.getName());
.....
}catch (final Throwable e){
log.log(Level.SEVERE, e.toString(), e);
}
This will print a nice stack trace on GAE's logs.
This way you don't have to change the global log level.
There are few things that you can possibly tweak:
1) In war\WEB-INF\logging.properties file. Change the .level value to a level lower e.g. DEBUG.
2) In your Java code, look at encapsulating the problem code within a try/catch so that you have control of the same.
3) In the catch block, look at logging the exception data via ex.printStackTrace(), where ex is the exception object.

Resources