assistant添加异常捕获,避免数据库死锁异常造成assistant中断
This commit is contained in:
		@@ -1,5 +1,7 @@
 | 
			
		||||
// 定时更新 wait 表
 | 
			
		||||
 | 
			
		||||
const sleepUtils = require("../../utils/sleepUtils");
 | 
			
		||||
 | 
			
		||||
// 计算数组差集 (a - b)
 | 
			
		||||
function getDiffSet(a, b) {
 | 
			
		||||
    // let a = [1, 2, 3];
 | 
			
		||||
@@ -45,11 +47,16 @@ async function migrateIdsFromCheckToFetch(tableName, fieldName, insertSql = null
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getPromise(tableName, fieldName, insertSql) {
 | 
			
		||||
    return new Promise(async function (resolve) {
 | 
			
		||||
        await migrateIdsFromCheckToFetch(tableName, fieldName, insertSql);
 | 
			
		||||
        resolve();
 | 
			
		||||
    });
 | 
			
		||||
async function getPromise(tableName, fieldName, insertSql) {
 | 
			
		||||
    try {
 | 
			
		||||
        return new Promise(async function (resolve) {
 | 
			
		||||
            await migrateIdsFromCheckToFetch(tableName, fieldName, insertSql);
 | 
			
		||||
            resolve();
 | 
			
		||||
        });
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
        console.error(e);
 | 
			
		||||
        await sleepUtils.sleep(10 * 1000);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
async function updateWaitTable() {
 | 
			
		||||
    await Promise.all([
 | 
			
		||||
 
 | 
			
		||||
@@ -84,7 +84,7 @@ async function main(args) {
 | 
			
		||||
 | 
			
		||||
            case 'assistant':
 | 
			
		||||
                await assistantUtils.updateWaitTable();
 | 
			
		||||
                await sleepUtils.sleep(5000);
 | 
			
		||||
                await sleepUtils.sleep(10 * 1000);
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                console.log("utils参数不匹配,退出");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user