AWS DynamoDB/DAX ValueError: invalid literal for int() with base 10: '//test.<chars>.dax-clusters.<region>.amazonaws.com'
AWS DynamoDB/DAX ValueError: invalid literal for int() with base 10: '//test.<chars>.dax-clusters.<region>.amazonaws.com'
我理解错误,但不确定为什么会发生。
with AmazonDaxClient.resource(
endpoint_url='daxs://test.<chars>.dax-clusters.<region>.amazonaws.com',
region_name='<region>'
) as dynamodb:
table = dynamodb.Table('<table_name>')
stmt = """
for i in range(3):
table.get_item(Key={
'id': str(i),
'date': str(dt + relativedelta(days=i))
})
"""
timer = timeit.Timer(stmt, globals={'relativedelta': relativedelta, 'dt': date.today(), 'table': table})
result = timer.repeat(repeat, n)
return result
我只是想对我可用的不同数据库进行一些 read/write 次基准测试,但无法让 DAX 工作,而通过 boto3 与 DynamoDB 的标准连接似乎工作正常。任何输入都会非常有帮助
编辑:
这是在 Lambda 上,这里是完整的错误消息:
{
"errorMessage": "invalid literal for int() with base 10: '//test.<chars>.dax-clusters.<region>.amazonaws.com'",
"errorType": "ValueError",
"stackTrace": [
" File \"/var/task/handler.py\", line 102, in handler\n results = test_func(repeat, n)\n",
" File \"/var/task/handler.py\", line 316, in test\n with AmazonDaxClient.resource(\n",
" File \"/var/task/amazondax/AmazonDaxClient.py\", line 86, in resource\n res = session.resource('dynamodb', region_name=region_name, api_version=api_version,\n",
" File \"/var/task/amazondax/Resource.py\", line 68, in resource\n res = super(DaxSession, self).resource('dynamodb',\n",
" File \"/var/task/boto3/session.py\", line 396, in resource\n client = self.client(\n",
" File \"/var/task/amazondax/Resource.py\", line 52, in client\n return AmazonDaxClient(self,\n",
" File \"/var/task/amazondax/AmazonDaxClient.py\", line 177, in __init__\n self._cluster = Cluster(self._region_name,\n",
" File \"/var/task/amazondax/Cluster.py\", line 30, in __init__\n self._discovery_endpoints = [_parse_host_ports(endpoint) for endpoint in discovery_endpoints]\n",
" File \"/var/task/amazondax/Cluster.py\", line 30, in <listcomp>\n self._discovery_endpoints = [_parse_host_ports(endpoint) for endpoint in discovery_endpoints]\n",
" File \"/var/task/amazondax/Cluster.py\", line 116, in _parse_host_ports\n return parts[0].strip(), int(parts[1].strip())\n"
]
}
最终将 endpoint_url
更改为 test.<chars>.dax-clusters.<region>.amazonaws.com
。这最终导致错误告诉我集群端点出现故障。我最终不得不确保在 DAX 集群正在使用的安全组的 inbound/outbound 规则中指定了 Lambda 的安全组。
我理解错误,但不确定为什么会发生。
with AmazonDaxClient.resource(
endpoint_url='daxs://test.<chars>.dax-clusters.<region>.amazonaws.com',
region_name='<region>'
) as dynamodb:
table = dynamodb.Table('<table_name>')
stmt = """
for i in range(3):
table.get_item(Key={
'id': str(i),
'date': str(dt + relativedelta(days=i))
})
"""
timer = timeit.Timer(stmt, globals={'relativedelta': relativedelta, 'dt': date.today(), 'table': table})
result = timer.repeat(repeat, n)
return result
我只是想对我可用的不同数据库进行一些 read/write 次基准测试,但无法让 DAX 工作,而通过 boto3 与 DynamoDB 的标准连接似乎工作正常。任何输入都会非常有帮助
编辑: 这是在 Lambda 上,这里是完整的错误消息:
{
"errorMessage": "invalid literal for int() with base 10: '//test.<chars>.dax-clusters.<region>.amazonaws.com'",
"errorType": "ValueError",
"stackTrace": [
" File \"/var/task/handler.py\", line 102, in handler\n results = test_func(repeat, n)\n",
" File \"/var/task/handler.py\", line 316, in test\n with AmazonDaxClient.resource(\n",
" File \"/var/task/amazondax/AmazonDaxClient.py\", line 86, in resource\n res = session.resource('dynamodb', region_name=region_name, api_version=api_version,\n",
" File \"/var/task/amazondax/Resource.py\", line 68, in resource\n res = super(DaxSession, self).resource('dynamodb',\n",
" File \"/var/task/boto3/session.py\", line 396, in resource\n client = self.client(\n",
" File \"/var/task/amazondax/Resource.py\", line 52, in client\n return AmazonDaxClient(self,\n",
" File \"/var/task/amazondax/AmazonDaxClient.py\", line 177, in __init__\n self._cluster = Cluster(self._region_name,\n",
" File \"/var/task/amazondax/Cluster.py\", line 30, in __init__\n self._discovery_endpoints = [_parse_host_ports(endpoint) for endpoint in discovery_endpoints]\n",
" File \"/var/task/amazondax/Cluster.py\", line 30, in <listcomp>\n self._discovery_endpoints = [_parse_host_ports(endpoint) for endpoint in discovery_endpoints]\n",
" File \"/var/task/amazondax/Cluster.py\", line 116, in _parse_host_ports\n return parts[0].strip(), int(parts[1].strip())\n"
]
}
最终将 endpoint_url
更改为 test.<chars>.dax-clusters.<region>.amazonaws.com
。这最终导致错误告诉我集群端点出现故障。我最终不得不确保在 DAX 集群正在使用的安全组的 inbound/outbound 规则中指定了 Lambda 的安全组。