Skip to content

dynamodb concurrent GetItem timeout on ubuntu22.04 #2518

Open
@howz97

Description

@howz97

Describe the bug

In an ubuntu22.04 environment, timeouts when concurrent GetItem requests are sent to dynamodb.
Here is my code

#include <atomic>
#include <iostream>

#include <aws/core/Aws.h>
#include <aws/dynamodb/DynamoDBClient.h>
#include <aws/dynamodb/model/GetItemRequest.h>

using namespace Aws::DynamoDB::Model;

constexpr uint num_threads = 100;
std::atomic<uint> counter = 0;

GetItemRequest get_rand_item_req() {
  GetItemRequest req;
  req.SetTableName("test.rand");
  req.SetConsistentRead(true);
  req.AddKey("id", AttributeValue().SetN(std::to_string(rand() % 1000)));
  return std::move(req);
}

void worker() {
  Aws::Client::ClientConfiguration config;
  config.region = "ap-northeast-1";
  Aws::DynamoDB::DynamoDBClient client(config);
  for (uint i = 0; i < 5; ++i) {
    GetItemRequest req = get_rand_item_req();
    GetItemOutcome outcome = client.GetItem(req);
    if (!outcome.IsSuccess()) {
      std::cout << outcome.GetError() << std::endl;
      break;
    }
    counter++;
  }
}

int main() {
  Aws::SDKOptions options;
  Aws::InitAPI(options);

  auto start = std::chrono::system_clock::now();
  std::vector<std::thread> workers;
  for (uint i = 0; i < num_threads; ++i) {
    workers.emplace_back(worker);
  }
  for (auto &w : workers) {
    w.join();
  }
  uint elapsed = std::chrono::duration_cast<std::chrono::seconds>(
                     std::chrono::system_clock::now() - start)
                     .count();
  std::cout << "finished counter " << counter << std::endl;
  std::cout << "elapsed seconds " << elapsed << std::endl;

  Aws::ShutdownAPI(options);
  return 0;
}

Expected Behavior

I expect it to output this without any error

finished counter 500
elapsed seconds 0

Current Behavior

HTTP response code: -1
Resolved remote host IP address: 13.248.70.8
Request ID:
Exception name:
Error message: curlCode: 28, Timeout was reached
0 response headers:
HTTP response code: -1
Resolved remote host IP address: 13.248.70.8
Request ID:
Exception name:
Error message: curlCode: 28, Timeout was reached
0 response headers:
finished counter 320
elapsed seconds 268

Reproduction Steps

  1. configure your aws credential
  2. compile this code
  3. run

Possible Solution

No response

Additional Information/Context

It worked fine if i set num_threads=1 so that GetItem is executed in only one thread.

finished counter 5
elapsed seconds 0

Or if i change the operating system to ubuntu20.04

AWS CPP SDK version used

1.11.90

Compiler and Version used

gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0

Operating System and version

Ubuntu 22.04.2 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions