-
Notifications
You must be signed in to change notification settings - Fork 28
Description
As I mentioned in #1, I have a set of tests which makes requests to a PHP-based API that in turn uses S3 for file storage.
Since the tests make actual requests (i.e. no functionality is mocked), each request have to finish within about one minute or the nginx server in front of the API times out.
Now, the tests creates a lot of requests to test the various API endpoints in different ways. The requests are done synchronously, so there should only be one request in flight at a time. Also, not all requests make use of S3, but those that do usually make multiple calls to S3.
For example, checking if a directory exists, create it if it doesn't and then upload a file to that directory (while S3 is not a file system, the AWS PHP SDK has functionality that allows working with S3 as if it is a regular file system using familiar operations). This is why there are a lot of HeadObject operations in the log below (404 -> the file or directory does not exist).
So to the issue: when running the tests and looking at the test script logs, it is clear that the API request is blocked for a while (the test log output stops). Most of the time it returns a response (after whatever blocked it finishes).
Looking at the localstack logs, it stops at the same time the test stops, and it seems to coincide with the Persisting state of service s3... log entry.
It's not clear what state is persisted, but it usually blocks the callee for a little while (a couple of seconds or so, not a big deal). The problem is that sometimes it is stuck a much longer time (>1 minute), which is enough for the nginx server in front of the API to abort the request and return a 504 Gateway Timeout to the client (in this case, the test script). I verified this by raising the timeouts in the nginx server until I could run the same tests multiple times without a timeout.
In the logs below, I marked the time the last test client request was blocked. After about a minute the request is aborted, but I believe the PHP script continues executing, which is why some S3 requests are made afterwards.
LocalStack version: 3.0.1.dev
LocalStack build date: 2023-11-21
LocalStack build git hash: f354fd43
2023-11-22T07:52:33.428 INFO --- [ MainThread] localstack_persist.state : Loading persisted state of all services...
2023-11-22T07:52:33.428 INFO --- [ MainThread] localstack_persist.state : Loading persisted state of service s3...
2023-11-22T07:52:33.984 INFO --- [ MainThread] localstack.utils.bootstrap : Execution of "_load_service_plugin" took 543.60ms
2023-11-22T07:52:34.053 INFO --- [-functhread4] hypercorn.error : Running on https://0.0.0.0:4566 (CTRL + C to quit)
2023-11-22T07:52:34.053 INFO --- [-functhread4] hypercorn.error : Running on https://0.0.0.0:4566 (CTRL + C to quit)
Ready.
2023-11-22T07:55:37.260 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:37.334 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:55:37.352 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:37.369 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:55:37.385 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 200
2023-11-22T07:55:37.411 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.CopyObject => 200
2023-11-22T07:55:38.177 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.ListObjects => 200
2023-11-22T07:55:38.462 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.DeleteObjects => 200
2023-11-22T07:55:38.730 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:38.758 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:55:38.780 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:38.801 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:55:38.819 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 200
2023-11-22T07:55:38.841 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.CopyObject => 200
2023-11-22T07:55:39.103 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.ListObjects => 200
2023-11-22T07:55:39.122 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.DeleteObjects => 200
2023-11-22T07:55:39.302 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:39.319 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:55:39.334 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:39.351 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:55:39.366 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 200
2023-11-22T07:55:39.381 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.CopyObject => 200
2023-11-22T07:55:43.991 INFO --- [ead-4 (_run)] localstack_persist.state : Persisting state of service s3...
2023-11-22T07:55:45.863 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.ListObjects => 200
2023-11-22T07:55:45.885 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.DeleteObjects => 200
2023-11-22T07:55:50.674 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:50.696 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:55:50.709 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:50.723 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:55:50.739 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 200
2023-11-22T07:55:50.765 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.CopyObject => 200
2023-11-22T07:55:51.432 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.ListObjects => 200
2023-11-22T07:55:51.451 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.DeleteObjects => 200
2023-11-22T07:55:51.693 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:55:51.711 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
blocks here --> 2023-11-22T07:55:54.036 INFO --- [ead-4 (_run)] localstack_persist.state : Persisting state of service s3...
2023-11-22T07:56:56.744 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 404 (NoSuchKey)
2023-11-22T07:56:56.762 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.PutObject => 200
2023-11-22T07:56:56.780 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.HeadObject => 200
2023-11-22T07:56:56.804 INFO --- [ asgi_gw_0] localstack.request.aws : AWS s3.CopyObject => 200
2023-11-22T07:57:04.044 INFO --- [ead-4 (_run)] localstack_persist.state : Persisting state of service s3...