guardian / ophan-housekeeper

Lambda to remove Ophan Email Alerts for bouncing email addresses
0 stars 1 forks source link

AWS Lambda errors involving Metaspace java.lang.OutOfMemoryError #4

Open rtyley opened 5 years ago

rtyley commented 5 years ago

https://logs.gutools.co.uk/s/ophan/app/kibana#/doc/581f7b00-c4df-11e9-bc08-9d1af4d9c1d5/logstash-ophan-2019.10.01?id=kFC2h20BPBaX1TI7AcCf&_g=()

{
  "_index": "logstash-ophan-2019.10.01",
  "_type": "_doc",
  "_id": "kFC2h20BPBaX1TI7AcCf",
  "_score": 1,
  "_source": {
    "cloudwatchLogGroup": "/aws/lambda/Ophan-Housekeeper-Lambda-KBZN4AWWA0W7",
    "source_stream": "ophan",
    "message": "Metaspace\njava.lang.OutOfMemoryError\n",
    "@timestamp": "2019-10-01T14:25:13.463Z",
    "@version": "1",
    "cloudwatchId": "35010829987141579251475991642521829641215342808301699079"
  },
  "fields": {
    "@timestamp": [
      "2019-10-01T14:25:13.463Z"
    ]
  }
}

From https://stackoverflow.com/a/38918849/438886 :

It would seem when creating any of the AWS clients (Sync or Async) you may get out of Metaspace.

I believe this is due to things that the Amazon Client is performing upon instantiation, including AmazonHttpClient creation as well as dynamic loading of request handler chains (part of AmazonEc2Client#init() private method).

From Paul Brown:

For people who are building Lambdas that perform HTTP call-outs it's worth knowing about the issue with the Apache HTTP Java library's classpath scanning which the new AWS Java SDK v2.0 lets you bypass: https://aws.amazon.com/blogs/developer/aws-sdk-for-java-2-0-developer-preview/.

... Customers who want to avoid potentially expensive classpath scanning can set the system property software.amazon.awssdk.http.service.impl to explicitly identify the implementation to use...