Using Python sdk to insert document with uuid

Hi,
I am using python sdk to load in a dataframe (with more than 30,000 rows) of json messages as below:

for j in range(len(data)):
    json_msg = json.loads(data['JSON'].iloc[j])
    json_msg_id = uuid.uuid4().__str__()

    try : 
        temp_collection.insert(json_msg_id, json_msg)
    except Exception as inst:
        print(inst.args)

Around 30 rows would throw exceptions as below:

({‘rc’: 207, ‘message’: ‘Operational Error’, ‘key’: ‘1f980c43-b92d-4f28-9503-9b0ad13c822f’, ‘error_context’: {‘status_code’: 134, ‘opaque’: 1271, ‘cas’: 0, ‘key’: ‘1f980c43-b92d-4f28-9503-9b0ad13c822f’, ‘bucket’: ‘temp_bucket’, ‘collection’: ‘temp_collection’, ‘scope’: ‘temp_scope’, ‘context’: ‘’, ‘ref’: ‘’, ‘endpoint’: ‘’, ‘type’: ‘KVErrorContext’}, ‘csrc_info’: (‘src/multiresult.c’, 332)},)

Each time when I run the program with the same dataframe, different set of rows would throw error messages and the pattern is inconsistent. Any idea how to further debug this?

brgds,
Millie

I tried not to use uuid and instead there is a unique field (a time stamp in string format) in the json message, and with the following revised code:

for j in range(len(data)):
    json_msg = json.loads(data['JSON'].iloc[j])
    pc_timestamp = json_msg.get('PC_time_stamp')

    try : 
            temp_collection.insert(pc_timestamp, json_msg)
    except Exception as inst:
        print(inst.args)

I would get the following exceptions instead:
({‘rc’: 207, ‘message’: ‘Operational Error’, ‘key’: ‘2021-01-20T04:15:38.468988+11:00’, ‘error_context’: {‘status_code’: 134, ‘opaque’: 2337, ‘cas’: 0, ‘key’: ‘2021-01-20T04:15:38.468988+11:00’, ‘bucket’: ‘temp_bucket’, ‘collection’: ‘temp_collection’, ‘scope’: ‘temp_scope’, ‘context’: ‘’, ‘ref’: ‘’, ‘endpoint’: ‘’, ‘type’: ‘KVErrorContext’}, ‘csrc_info’: (‘src/multiresult.c’, 332)},)

so I presume this error is not related to uuid??

Hi @mzw

The server is returning an error indicating that it has run out of memory and can’t process requests right now. This can happen with batch load operations and an undersized server environment. You can either retry these failing operations with a backoff or increase the memory quota of your bucket.