pgdump-aws-lambda icon indicating copy to clipboard operation
pgdump-aws-lambda copied to clipboard

Keeping getting pg_dump process failed: error

Open yodaguLeader opened this issue 2 years ago • 4 comments

Hello,

I'm getting an error while testing the lambda:

Event:

{
    "PGDATABASE": "db_test",
    "PGUSER": "postgres",
    "PGPASSWORD": "12345",
    "PGHOST": "database-test-1.cluster-abcde.us-west-1.rds.amazonaws.com",
    "S3_BUCKET" : "bucket1",
    "ROOT": "hourly-backups"
}

Error log:

START RequestId: 123 Version: $LATEST
2022-04-12T19:39:06.383Z	123	ERROR	Error: pg_dump process failed: pg_dump: error: connection to database "db_test" failed: timeout expired

    at ChildProcess.<anonymous> (/var/task/lib/pgdump.js:54:21)
    at ChildProcess.emit (events.js:400:28)
    at ChildProcess.emit (domain.js:475:12)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
2022-04-12T19:39:06.383Z	123	ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"pg_dump process failed: pg_dump: error: connection to database \"db_test\" failed: timeout expired\n","stack":["Error: pg_dump process failed: pg_dump: error: connection to database \"db_test\" failed: timeout expired","","    at ChildProcess.<anonymous> (/var/task/lib/pgdump.js:54:21)","    at ChildProcess.emit (events.js:400:28)","    at ChildProcess.emit (domain.js:475:12)","    at maybeClose (internal/child_process.js:1058:16)","    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)"]}
REPORT RequestId: 123	Duration: 15624.90 ms	Billed Duration: 15625 ms	Memory Size: 128 MB	Max Memory Used: 84 MB	Init Duration: 562.19 ms	

These are the logs I'm getting.

The credentials are correct and I can successfully connect to my db from my local machine. Can it be due to my postgresql version is 10.14?

yodaguLeader avatar Apr 12 '22 19:04 yodaguLeader

Me too, kind of. I got this error.

START RequestId: 684cd75c-2daa-4bab-b2e1-4f29338242ce Version: $LATEST END RequestId: 684cd75c-2daa-4bab-b2e1-4f29338242ce REPORT RequestId: 684cd75c-2daa-4bab-b2e1-4f29338242ce Duration: 3013.76 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 33 MB 2022-06-03T17:01:26.293Z 684cd75c-2daa-4bab-b2e1-4f29338242ce Task timed out after 3.01 seconds

christiaanwesterbeek avatar Jun 03 '22 17:06 christiaanwesterbeek

The root cause is lambda function timeout. In my case I missed the instruction to go to tab "Configuration" -> "General Configuration" -> "Edit" and set timeout to 15 minutes, which is the maximum for an aws lambda by the way! The timeout of my lambda was still 3s seconds (the default).

The error you and I were getting is simply the fact that the lambda was running longer than the configured timeout.

I see yours was timing out after ~15000ms. That means your database is simply to large to be stream-dumped by this lambda function.

christiaanwesterbeek avatar Jun 03 '22 17:06 christiaanwesterbeek

Hello,

I'm getting an error while testing the lambda:

Event:

{
    "PGDATABASE": "db_test",
    "PGUSER": "postgres",
    "PGPASSWORD": "12345",
    "PGHOST": "database-test-1.cluster-abcde.us-west-1.rds.amazonaws.com",
    "S3_BUCKET" : "bucket1",
    "ROOT": "hourly-backups"
}

Error log:

START RequestId: 123 Version: $LATEST
2022-04-12T19:39:06.383Z	123	ERROR	Error: pg_dump process failed: pg_dump: error: connection to database "db_test" failed: timeout expired

    at ChildProcess.<anonymous> (/var/task/lib/pgdump.js:54:21)
    at ChildProcess.emit (events.js:400:28)
    at ChildProcess.emit (domain.js:475:12)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
2022-04-12T19:39:06.383Z	123	ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"pg_dump process failed: pg_dump: error: connection to database \"db_test\" failed: timeout expired\n","stack":["Error: pg_dump process failed: pg_dump: error: connection to database \"db_test\" failed: timeout expired","","    at ChildProcess.<anonymous> (/var/task/lib/pgdump.js:54:21)","    at ChildProcess.emit (events.js:400:28)","    at ChildProcess.emit (domain.js:475:12)","    at maybeClose (internal/child_process.js:1058:16)","    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)"]}
REPORT RequestId: 123	Duration: 15624.90 ms	Billed Duration: 15625 ms	Memory Size: 128 MB	Max Memory Used: 84 MB	Init Duration: 562.19 ms	

These are the logs I'm getting.

The credentials are correct and I can successfully connect to my db from my local machine. Can it be due to my postgresql version is 10.14?

I'am getting the same error

achrefnasri avatar Jun 13 '22 06:06 achrefnasri

I think my earlier comment was wrong on multiple levels. 15000ms does not equal 15 minutes 🤦. And also the lambda function timeout cause was only applicable for the error that I was having, and not OP's. You may ignore my comments.

christiaanwesterbeek avatar Jun 13 '22 11:06 christiaanwesterbeek