Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
languagejs
File "/usr/local/lib/python3.6/site-packages/tdclient/bulk_import_api.py", line 31, in create_bulk_import self.raise_error("Create bulk import failed", res, body) File 
File "/usr/local/lib/python3.6/site-packages/tdclient/api.py", line 367, in raise_error raise errors.AlreadyExistsError("%s: %s" % (msg, s)) tdclient 
tdclient.errors.AlreadyExistsError: Create bulk import failed: 
{
  "error":"[\"Name has already been taken\"]",
  "message":"[\"Name has already been taken\"]",
  "text":"[\"Name has already been taken\"]",
  "severity":"error",
  "status_code":409

1. Description

create_bulk_import failed with an error.

2. Cause

Job is executing the same exact query twice will cause two distinct queries to be executed on Treasure Data.

Code Block
print(f'Writing to table {schema_name}.{table_name}') session_name = "session-%d" % (int(time.time()),) bulk 
bulk_import = self.tdclient.create_bulk_import(session_name, schema_name, table_name)

session_name was not unique which caused to fail.

3. Resolution

Submit a job with unique session_name. Add the random number to the session name.

Code Block
print(f'Writing to table {schema_name}.{table_name}') session_name = "session-%d-%d" % (int(time.time()),random.randint(1,10001)),) bulk 
bulk_import = self.tdclient.create_bulk_import(session_name, schema_name, table_name) 

4. Note / Related Information

https://support.treasuredata.com/hc/en-us/articles/360001260527-REST-API#Job%20Request%20Idempotency