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

fix: Missing Ingestion Jobs from WebUI Table #679

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AVMatthews
Copy link
Contributor

@AVMatthews AVMatthews commented Jan 20, 2025

Description

#667

When ingestion jobs are submitted at a fast enough pace the ingestion table in the UI would be missing some of the submitted jobs. The ingestion table would request the most recent 5 jobs when looking for jobs and if job came quicker in the previous time period, not all jobs would be reflected in the UI.

FIX:

  • Remove job limit
  • Add time stamps for when updates occur to the compression jobs table
  • Maintain global last update request timestamp
  • Request updates for all jobs which were updated after the last update request timestamp

Validation performed

Submitted increasingly large number soft background compression jobs and made sure that they were all reflected in the table and that the updated to the status in the ingestion table occur accordingly.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new update_time column to track the last update timestamp for compression jobs.
    • Enhanced job tracking with more detailed update information.
  • Improvements

    • Updated job retrieval mechanism to use date-based filtering instead of fixed job limits.
    • Added "Last Updated" column in the ingestion jobs view to display job update times.
  • User Interface

    • New column in job listing showing the timestamp of the most recent job update.

The changes provide more granular tracking and visibility into compression job status and history.

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Walkthrough

The pull request introduces a new update_time column to the compression jobs table across multiple components. This change enhances job tracking by adding a timestamp to record when job metadata is updated. The modifications span the database initialization, job scheduler, web UI constants, database management, and user interface components, ensuring consistent tracking of job update times.

Changes

File Change Summary
components/clp-py-utils/clp_py_utils/initialize-orchestration-db.py Added update_time column to COMPRESSION_JOBS_TABLE_NAME as DATETIME(3) NULL DEFAULT NULL
components/job-orchestration/job_orchestration/scheduler/compress/compression_scheduler.py Updated job metadata updates to include update_time timestamp
components/webui/imports/api/ingestion/constants.js Added UPDATE_TIME: "update_time" to COMPRESSION_JOBS_TABLE_COLUMN_NAMES enum
components/webui/imports/api/ingestion/server/CompressionDbManager.js Modified getCompressionJobs method to use lastUpdateDate instead of limit
components/webui/imports/api/ingestion/server/publications.js Removed COMPRESSION_MAX_RETRIEVE_JOBS, added CONST_FOR_DATE_FORMAT and lastUpdateDate
components/webui/imports/ui/IngestView/panels/IngestionJobs/IngestionJobRow.jsx Added table cell to display job's update_time
components/webui/imports/ui/IngestView/panels/IngestionJobs/index.jsx Added "Last Updated" column to job table header

Possibly related issues

  • [Zulip] Missing ingest jobs #667 (Missing ingest jobs): The changes to job retrieval and tracking might help address the issue of missing job history by introducing a more robust date-based retrieval mechanism instead of a fixed limit.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fc3454 and 433c66b.

📒 Files selected for processing (1)
  • components/job-orchestration/job_orchestration/scheduler/compress/compression_scheduler.py (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/job-orchestration/job_orchestration/scheduler/compress/compression_scheduler.py
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-check (ubuntu-latest)
  • GitHub Check: lint-check (macos-latest)
  • GitHub Check: build (macos-latest)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
components/webui/imports/api/ingestion/server/CompressionDbManager.js (2)

26-31: Update JSDoc to reflect parameter changes.

The JSDoc comment still references the removed limit parameter. Please update it to describe the lastUpdateDate parameter.

- * Retrieves the last `limit` number of jobs and the ones with the given
+ * Retrieves jobs updated since the given date and the ones with the given
 * @param {string} lastUpdateDate

62-64: Consider optimizing the SQL query structure.

The current implementation adds the UPDATE_TIME filter to each UNION query, which could impact performance. Consider moving the filter to a WHERE clause after the UNION to improve query efficiency.

- WHERE 
-     _id=${jobId} && 
-     ${COMPRESSION_JOBS_TABLE_COLUMN_NAMES.UPDATE_TIME} >= '${lastUpdateDate}'
+ WHERE _id=${jobId}

Then add after all UNION queries:

WHERE ${COMPRESSION_JOBS_TABLE_COLUMN_NAMES.UPDATE_TIME} >= '${lastUpdateDate}'
components/webui/imports/ui/IngestView/panels/IngestionJobs/IngestionJobRow.jsx (1)

109-115: Consider using dayjs for consistent date formatting.

The component already uses dayjs for duration calculations. For consistency, consider using it for formatting update_time as well.

- text={(null === job.update_time) ?
-     "null" :
-     new Date(job.update_time).toLocaleString()}/>
+ text={(null === job.update_time) ?
+     "null" :
+     dayjs(job.update_time).format('YYYY-MM-DD HH:mm:ss')}/>
components/webui/imports/api/ingestion/server/publications.js (2)

23-23: Add a comment explaining the magic number.

The constant CONST_FOR_DATE_FORMAT = 19 is used for date string manipulation but its purpose isn't clear. Add a comment explaining that it represents the length of the MySQL datetime format "YYYY-MM-DD HH:MM:SS".

+// Length of MySQL datetime format "YYYY-MM-DD HH:MM:SS"
 const CONST_FOR_DATE_FORMAT = 19;

48-50: Extract date formatting logic into a helper function.

The date string manipulation logic is duplicated. Extract it into a reusable helper function to improve maintainability.

+/**
+ * Formats a date object to MySQL datetime format
+ * @param {Date} date
+ * @return {string}
+ */
+const formatToMySQLDateTime = (date) => {
+    return date.toISOString()
+        .slice(0, CONST_FOR_DATE_FORMAT)
+        .replace("T", " ");
+};
+
-let lastUpdateDate = new Date().toISOString()
-    .slice(0, CONST_FOR_DATE_FORMAT)
-    .replace("T", " ");
+let lastUpdateDate = formatToMySQLDateTime(new Date());

 // In refreshCompressionJobs:
-    const newDate = new Date().toISOString()
-        .slice(0, CONST_FOR_DATE_FORMAT)
-        .replace("T", " ");
+    const newDate = formatToMySQLDateTime(new Date());

Also applies to: 107-109

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba63a76 and 0a3c885.

📒 Files selected for processing (7)
  • components/clp-py-utils/clp_py_utils/initialize-orchestration-db.py (1 hunks)
  • components/job-orchestration/job_orchestration/scheduler/compress/compression_scheduler.py (5 hunks)
  • components/webui/imports/api/ingestion/constants.js (1 hunks)
  • components/webui/imports/api/ingestion/server/CompressionDbManager.js (3 hunks)
  • components/webui/imports/api/ingestion/server/publications.js (3 hunks)
  • components/webui/imports/ui/IngestView/panels/IngestionJobs/IngestionJobRow.jsx (1 hunks)
  • components/webui/imports/ui/IngestView/panels/IngestionJobs/index.jsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
components/webui/imports/ui/IngestView/panels/IngestionJobs/index.jsx (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

components/webui/imports/api/ingestion/constants.js (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

components/webui/imports/ui/IngestView/panels/IngestionJobs/IngestionJobRow.jsx (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

components/webui/imports/api/ingestion/server/CompressionDbManager.js (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

components/webui/imports/api/ingestion/server/publications.js (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-check (ubuntu-latest)
  • GitHub Check: lint-check (macos-latest)
  • GitHub Check: build (macos-latest)
🔇 Additional comments (4)
components/webui/imports/api/ingestion/constants.js (1)

13-13: LGTM! The new UPDATE_TIME constant is well-placed.

The addition follows the existing naming convention and maintains logical grouping with other time-related columns.

components/webui/imports/ui/IngestView/panels/IngestionJobs/index.jsx (1)

50-50: LGTM! The new column header is well-integrated.

The "Last Updated" column follows the existing table design pattern with consistent right alignment.

components/clp-py-utils/clp_py_utils/initialize-orchestration-db.py (1)

58-58: LGTM! The update_time column addition is well-structured.

The column definition aligns with other timestamp columns in the table and is appropriately positioned with other time-related fields.

components/job-orchestration/job_orchestration/scheduler/compress/compression_scheduler.py (1)

212-219: LGTM! Consistent timestamp updates across all job state changes.

The update_time is properly set at all critical points where job status changes:

  • When no tasks are created
  • When job starts
  • When job succeeds
  • When job fails

Also applies to: 233-235, 339-339, 350-350

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
components/webui/imports/api/ingestion/server/publications.js (1)

106-112: ⚠️ Potential issue

Prevent potential race condition in lastUpdateDate updates.

The current implementation has a potential race condition where jobs updated between saving newDate and updating lastUpdateDate could be missed. Consider using a transaction or updating lastUpdateDate before the query.

Additionally, consider adding error handling for date operations to prevent potential runtime errors.

#!/bin/bash
# Description: Check for potential race conditions by analyzing job update patterns

# Search for concurrent job updates in the codebase
rg -A 5 "UPDATE.*COMPRESSION_JOBS.*SET" 
🧹 Nitpick comments (2)
components/webui/imports/api/ingestion/server/publications.js (2)

23-24: Document the significance of the magic number.

The constant CONST_FOR_DATE_FORMAT = 19 appears to be the length of a MySQL datetime string (YYYY-MM-DD HH:mm:ss). Consider adding a comment explaining this or using a more descriptive constant name.

+// Length of MySQL datetime string format 'YYYY-MM-DD HH:mm:ss'
 const CONST_FOR_DATE_FORMAT = 19;

45-51: Extract date formatting logic into a reusable function.

The date formatting logic is duplicated between initialization and updates. Consider extracting it into a helper function to improve maintainability and reduce duplication.

+/**
+ * Formats a Date object to MySQL datetime string format
+ * @param {Date} date - The date to format
+ * @return {string} Formatted date string in 'YYYY-MM-DD HH:mm:ss' format
+ */
+const formatToMySQLDateTime = (date) => {
+    return date.toISOString()
+        .slice(0, CONST_FOR_DATE_FORMAT)
+        .replace("T", " ");
+};
+
-let lastUpdateDate = new Date().toISOString()
-    .slice(0, CONST_FOR_DATE_FORMAT)
-    .replace("T", " ");
+let lastUpdateDate = formatToMySQLDateTime(new Date());
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a3c885 and 1fc3454.

📒 Files selected for processing (1)
  • components/webui/imports/api/ingestion/server/publications.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
components/webui/imports/api/ingestion/server/publications.js (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant