Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enterprise Search] Fix logic for long running and orphaned jobs #145714

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions x-pack/plugins/enterprise_search/server/lib/stats/get_sync_jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export const fetchSyncJobsStats = async (client: IScopedClusterClient): Promise<
const orphanedJobsCountResponse = await client.asCurrentUser.count({
index: CONNECTORS_JOBS_INDEX,
query: {
terms: {
'connector.id': ids,
bool: {
must_not: [
{
terms: {
'connector.id': ids,
},
},
],
},
},
});
Expand All @@ -51,7 +57,7 @@ export const fetchSyncJobsStats = async (client: IScopedClusterClient): Promise<
},
{
range: {
last_seen: {
started_at: {
lt: moment().subtract(1, 'day').toISOString(),
},
},
Expand All @@ -62,10 +68,10 @@ export const fetchSyncJobsStats = async (client: IScopedClusterClient): Promise<
});

const errorResponse = await client.asCurrentUser.count({
index: CONNECTORS_JOBS_INDEX,
index: CONNECTORS_INDEX,
query: {
term: {
status: SyncStatus.ERROR,
last_sync_status: SyncStatus.ERROR,
},
},
});
Expand Down Expand Up @@ -109,7 +115,7 @@ export const fetchSyncJobsStats = async (client: IScopedClusterClient): Promise<
{
range: {
last_seen: {
gt: moment().subtract(30, 'minutes').toISOString(),
lt: moment().subtract(30, 'minutes').toISOString(),
},
},
},
Expand Down