Under high concurrency, Tortoise-ORM executed an update statement, but the data in the database didn't change, and there were no error messages either. What could be the reason for this?
this is my code:
async def update_database_record(model, xs_id: str, updates: dict): async with in_transaction('default'): instance = await model.get(id=xs_id) instance.update_from_dict(updates) await instance.save() logger.info(f"更新数据库记录, model:{model}, xs_id:{xs_id}, updates:{updates}")
Under high concurrency, Tortoise-ORM executed an update statement, but the data in the database didn't change, and there were no error messages either. What could be the reason for this?
this is my code:
async def update_database_record(model, xs_id: str, updates: dict): async with in_transaction('default'): instance = await model.get(id=xs_id) instance.update_from_dict(updates) await instance.save() logger.info(f"更新数据库记录, model:{model}, xs_id:{xs_id}, updates:{updates}")
this is log:
2024-08-01 19:30:19,056 - DEBUG - tortoise.db_client:197 - 19233 - 139634569598784 - UPDATE
DD_APP_ROBOT_PATCH_MESSAGE_RECORDSET
ORI_CHN=%s,
ORI_SYS=%s,
ORI_SEQ=%s,
POST_TIME=%s,
RECEIVE_TIME=%s,
RETURN_MSG=%s,
SEND_STATUS=%s,
CODE=%s,
ROBOT_CODE=%s,
IDTYPE=%s,
USERIDS=%s,
TRANS_USERIDS=%s,
MSGKEY=%s,
MSGPARAM=%s,
REQ_DATA=%s,
PROCESSQUERYKEY=%s,
INVALIDSTAFFIDLIST=%s,
FLOWCONTROLLEDSTAFFIDLIST=%s WHERE
ID=%s: ['LH', 'xebzh', 'test20240801002', datetime.datetime(2024, 8, 1, 19, 30, 18, 357469, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>), datetime.datetime(2024, 8, 1, 19, 30, 19, 56569, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>), '调用接口成功', 'success', 200, '', 2, "['014401']", '', 'sampleText', "{'content':'并发测试xebzh0801'}", '{"idtype":2,"msgKey":"sampleText","ori_chn":"LH","ori_seq":"test20240801002","ori_sys":"xebzh","userIds":["014401"],"msgParam":"{\'content\':\'并发测试 xebzh0801\'}"}', 'b9RN5kwxEtRhX7HP2KYwVRNkvmUzqMuIctZ37nvbM+Y=', '[]', '[]', '006073f9-4752-409b-aa5b-54e082267899']