Skip to content

Conversation

@sitaowang1998
Copy link
Collaborator

@sitaowang1998 sitaowang1998 commented Jun 2, 2025

Description

Spider sets MySQL tables for jobs, task instance and schedulers start timestamp ON UPDATE CURRENT_TIMESTAMP, which changes the timestamp every time the table is updated, making it an update timestamp instead.

This pr solves this issue by removing the ON UPDATE CURRENT_TIMESTAMP.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • GitHub workflows pass.
  • Unit tests pass in dev container.
  • Integration tests pass in dev container.

Summary by CodeRabbit

  • Refactor
    • Updated timestamp columns in several tables so they are set only at row creation and no longer update automatically when the row is modified. This affects the creation time in jobs, start time in task instances, and lease time in scheduler leases.

@sitaowang1998 sitaowang1998 requested a review from a team as a code owner June 2, 2025 20:38
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 2, 2025

Walkthrough

The changes remove the ON UPDATE CURRENT_TIMESTAMP clause from the default value definitions of three TIMESTAMP columns in MySQL table creation statements. Now, these columns are set to the current timestamp only upon row insertion and do not update automatically on subsequent row modifications.

Changes

File(s) Change Summary
src/spider/storage/mysql/mysql_stmt.hpp Removed ON UPDATE CURRENT_TIMESTAMP from TIMESTAMP columns in SQL table schema string constants.
tools/scripts/storage/init_db.sql Updated TIMESTAMP column definitions to exclude ON UPDATE CURRENT_TIMESTAMP in schema SQL.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant MySQL
    participant Table

    Client->>MySQL: INSERT INTO jobs/task_instances/scheduler_leases
    MySQL->>Table: Set TIMESTAMP column to CURRENT_TIMESTAMP

    Client->>MySQL: UPDATE jobs/task_instances/scheduler_leases
    MySQL->>Table: TIMESTAMP column remains unchanged
Loading

📜 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 6b7e5ff and 49091b7.

📒 Files selected for processing (2)
  • src/spider/storage/mysql/mysql_stmt.hpp (2 hunks)
  • tools/scripts/storage/init_db.sql (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: non-storage-unit-tests (ubuntu-24.04)
  • GitHub Check: non-storage-unit-tests (ubuntu-22.04)
  • GitHub Check: lint
🔇 Additional comments (6)
src/spider/storage/mysql/mysql_stmt.hpp (3)

27-27: Remove ON UPDATE clause from creation_time
The creation_time column now defaults to CURRENT_TIMESTAMP only on insert, preserving the original job creation timestamp on subsequent updates. This change aligns with the intended semantics and matches the corresponding init SQL script.


107-107: Remove ON UPDATE clause from start_time
The start_time in task_instances will now remain fixed at the time the instance was first created, preventing unintended modifications during later updates.


115-115: Remove ON UPDATE clause from lease_time
With lease_time defaulting only on insert, scheduler leases will correctly reflect the initial acquisition time and won’t change on row updates.

tools/scripts/storage/init_db.sql (3)

19-19: Remove ON UPDATE clause from jobs.creation_time
The creation_time column in the jobs table now only captures the insert timestamp, ensuring the original creation time is preserved.


106-106: Remove ON UPDATE clause from task_instances.start_time
The start_time column now remains constant at the moment of insertion, preventing it from updating on later row modifications.


114-114: Remove ON UPDATE clause from scheduler_leases.lease_time
The lease_time will correctly reflect only the initial lease acquisition timestamp, and won’t auto-update on subsequent changes.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

@sitaowang1998 sitaowang1998 requested a review from davidlion June 2, 2025 20:41
@davidlion davidlion changed the title fix(storage): Do not update start timestamp for job, task instance and scheduler lease (fixes #145). fix(storage): Do not update start timestamp for job, task instance, and scheduler lease (fixes #145). Jul 7, 2025
Copy link
Member

@davidlion davidlion left a comment

Choose a reason for hiding this comment

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

lgtm, but please update the title to follow the guidelines:
https://www.notion.so/yscope/WIP-Contribution-Guidelines-4073935a066a4095aa45a6755daf6fa6?source=copy_link#7a2271306db844b8b072c55a4e8ddf88

Also, why is GitHub workflows pass. not checked?

@sitaowang1998 sitaowang1998 changed the title fix(storage): Do not update start timestamp for job, task instance, and scheduler lease (fixes #145). fix(storage): Stop updating start timestamp on job, task instance, and scheduler lease table change (fixes #145). Jul 7, 2025
@sitaowang1998 sitaowang1998 requested a review from davidlion July 7, 2025 18:00
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.

2 participants