fixing high cpu usage after some time
retryinfo was not being updated and not being used by exchangeCheckRefresh pending operation
This commit is contained in:
parent
5eeb00e158
commit
f6ec105b72
@ -123,7 +123,7 @@ async function handleExchangeUpdateError(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await ws.db
|
await ws.db
|
||||||
.mktx((x) => ({ exchanges: x.exchanges }))
|
.mktx((x) => ({ exchanges: x.exchanges }))
|
||||||
.runReadOnly(async (tx) => {
|
.runReadWrite(async (tx) => {
|
||||||
const exchange = await tx.exchanges.get(baseUrl);
|
const exchange = await tx.exchanges.get(baseUrl);
|
||||||
if (!exchange) {
|
if (!exchange) {
|
||||||
return;
|
return;
|
||||||
@ -131,6 +131,7 @@ async function handleExchangeUpdateError(
|
|||||||
exchange.retryInfo.retryCounter++;
|
exchange.retryInfo.retryCounter++;
|
||||||
updateRetryInfoTimeout(exchange.retryInfo);
|
updateRetryInfoTimeout(exchange.retryInfo);
|
||||||
exchange.lastError = err;
|
exchange.lastError = err;
|
||||||
|
await tx.exchanges.put(exchange)
|
||||||
});
|
});
|
||||||
if (err) {
|
if (err) {
|
||||||
ws.notify({ type: NotificationType.ExchangeOperationError, error: err });
|
ws.notify({ type: NotificationType.ExchangeOperationError, error: err });
|
||||||
@ -526,11 +527,11 @@ async function updateExchangeFromUrlImpl(
|
|||||||
tosFound !== undefined
|
tosFound !== undefined
|
||||||
? tosFound
|
? tosFound
|
||||||
: await downloadExchangeWithTermsOfService(
|
: await downloadExchangeWithTermsOfService(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
ws.http,
|
ws.http,
|
||||||
timeout,
|
timeout,
|
||||||
"text/plain",
|
"text/plain",
|
||||||
);
|
);
|
||||||
|
|
||||||
let recoupGroupId: string | undefined = undefined;
|
let recoupGroupId: string | undefined = undefined;
|
||||||
|
|
||||||
|
@ -51,25 +51,18 @@ async function gatherExchangePending(
|
|||||||
resp: PendingOperationsResponse,
|
resp: PendingOperationsResponse,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await tx.exchanges.iter().forEachAsync(async (e) => {
|
await tx.exchanges.iter().forEachAsync(async (e) => {
|
||||||
let exchangeUpdateTimestampDue: Timestamp;
|
|
||||||
|
|
||||||
if (e.lastError) {
|
|
||||||
exchangeUpdateTimestampDue = e.retryInfo.nextRetry;
|
|
||||||
} else {
|
|
||||||
exchangeUpdateTimestampDue = e.nextUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: PendingTaskType.ExchangeUpdate,
|
type: PendingTaskType.ExchangeUpdate,
|
||||||
givesLifeness: false,
|
givesLifeness: false,
|
||||||
timestampDue: exchangeUpdateTimestampDue,
|
timestampDue: e.lastError ? e.retryInfo.nextRetry : e.nextUpdate,
|
||||||
exchangeBaseUrl: e.baseUrl,
|
exchangeBaseUrl: e.baseUrl,
|
||||||
lastError: e.lastError,
|
lastError: e.lastError,
|
||||||
});
|
});
|
||||||
|
|
||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: PendingTaskType.ExchangeCheckRefresh,
|
type: PendingTaskType.ExchangeCheckRefresh,
|
||||||
timestampDue: e.nextRefreshCheck,
|
timestampDue: e.lastError ? e.retryInfo.nextRetry : e.nextRefreshCheck,
|
||||||
givesLifeness: false,
|
givesLifeness: false,
|
||||||
exchangeBaseUrl: e.baseUrl,
|
exchangeBaseUrl: e.baseUrl,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user