Skip to content

fix: Increse size of type and value in task input/output and size of data - #92

Closed
sitaowang1998 wants to merge 2 commits into
y-scope:mainfrom
sitaowang1998:db_size
Closed

fix: Increse size of type and value in task input/output and size of data#92
sitaowang1998 wants to merge 2 commits into
y-scope:mainfrom
sitaowang1998:db_size

Conversation

@sitaowang1998

@sitaowang1998 sitaowang1998 commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator

Description

The size of type and value task input/output is set to 64 and 256, while size of data is set to 256. These numbers are too small for real-world production.

This pr also increases the above mentioned sizes. Fixes #68.

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

  • Chores
    • Increased the storage capacity for various data fields, allowing the system to handle larger data entries and improve overall flexibility.

@sitaowang1998
sitaowang1998 requested a review from a team as a code owner April 3, 2025 18:14
@coderabbitai

coderabbitai Bot commented Apr 3, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request increases the maximum allowed lengths for certain columns in several database tables. Both the C++ header file used for table definitions and the SQL initialisation script have been updated. The changes expand the size of the type and value columns used in the task_inputs, task_outputs, data, client_kv_data, and task_kv_data tables, allowing for larger payloads.

Changes

Files Change Summary
src/spider/.../mysql_stmt.hpp
tools/scripts/.../init_db.sql
Increased maximum lengths: updated task_inputs and task_outputs (type: VARCHAR(64) → VARCHAR(999); value: VARBINARY(64) → VARBINARY(999)); updated data (value: VARBINARY(256) → VARBINARY(999)); updated client_kv_data and task_kv_data (value: VARBINARY(128) → VARBINARY(999)).

Assessment against linked issues

Objective Addressed Explanation
Expand size of task input/output in database (#68)

Possibly related PRs

✨ 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.
    • 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/spider/storage/mysql/mysql_stmt.hpp (1)

157-174: Consider documenting migration path for existing databases.

While the schema changes are consistent across files, there's no information about how existing databases should be migrated to the new schema. Consider adding documentation or a migration script for existing deployments.

Would you like me to generate a sample SQL migration script to update existing database schemas to match these changes?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9949aa5 and 0982690.

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

61-61: Good adjustment to the VARBINARY size for the data table value field.

The increase from 256 to 999 bytes for the value column will allow for storing larger data payloads, addressing the issue mentioned in PR objectives about insufficient sizes for real-world production scenarios.


70-71: Increased sizes for task_outputs columns is appropriate.

The change from VARCHAR(64) to VARCHAR(999) for type and VARBINARY(64) to VARBINARY(999) for value will accommodate more complex type descriptors and larger output values, aligning with the PR objectives.


81-84: Appropriate size increase for task_inputs columns.

The larger sizes for type (VARCHAR(999)) and value (VARBINARY(999)) columns will ensure that task inputs can handle more complex data structures and larger payloads as required in production environments.


138-138: Good adjustment for client_kv_data value field size.

Increasing the value column from VARBINARY(128) to VARBINARY(999) will allow clients to store larger key-value data as needed in production environments.


145-145: Appropriate size increase for task_kv_data value field.

The increase of the value column from VARBINARY(128) to VARBINARY(999) is consistent with the other changes and addresses the need for larger data storage in task key-value pairs.

src/spider/storage/mysql/mysql_stmt.hpp (6)

70-73: Good alignment with SQL schema changes for task_inputs.

The changes to increase the type and value columns to VARCHAR(999) and VARBINARY(999) respectively match the changes in the init_db.sql file, ensuring consistency between code and database schema.


84-85: Properly synchronized task_outputs column size changes.

The increases to VARCHAR(999) for type and VARBINARY(999) for value match the corresponding changes in the init_db.sql file, maintaining schema consistency.


111-111: Consistent data value column size increase.

The change from VARBINARY(256) to VARBINARY(999) for the value column in the data table matches the SQL schema change, ensuring consistency.


144-144: Consistent client_kv_data value size adjustment.

The increase to VARBINARY(999) for the value column properly aligns with the corresponding change in the init_db.sql file.


151-151: Correctly synchronized task_kv_data value column size.

The increase to VARBINARY(999) for the value column matches the change in the init_db.sql file, maintaining schema consistency.


111-111:

Details

❓ Verification inconclusive

Consider the specific choice of 999 for column sizes.

The consistent choice of 999 bytes (rather than 1000, 1024, etc.) for all affected columns is interesting. Is there a specific reason for this value? Consider whether this size will be sufficient for future needs or if a more generous size would prevent another increase later.

Also applies to: 70-73, 84-85, 144-144, 151-151


🌐 Web query:

What is the practical maximum size for MySQL VARBINARY columns?

💡 Result:

The practical maximum size for a VARBINARY column in MySQL is 65,535 bytes, but this is subject to the following constraints:

  1. Row Size Limit:
    The total row size (including all columns) cannot exceed MySQL’s maximum row size of 65,535 bytes[3][6][9]. For example:

    • A table with a single VARBINARY(65535) column is valid.
    • If other columns exist, their combined size reduces the maximum allowed VARBINARY length[3][9].
  2. Storage Engine Impact:
    InnoDB imposes additional constraints. For tables using the default 16KB page size, rows must fit within ~8KB for on-page storage. Larger VARBINARY values may trigger off-page storage (via overflow pages), but this depends on the ROW_FORMAT (e.g., DYNAMIC allows efficient off-page storage for large values)[8].

  3. Alternatives for Larger Data:
    For binary data exceeding 65,535 bytes, use BLOB types:

    • BLOB: Up to 65,535 bytes (inline storage, contributes to row size).
    • MEDIUMBLOB: Up to 16MB.
    • LONGBLOB: Up to 4GB[2][6][9].

Example Scenarios

Use Case Recommended Type Maximum Size Notes
Small binary data (e.g., flags, short hashes) VARBINARY(255) ≤65,535 bytes Fits entirely within row.
Large files (e.g., images, PDFs) LONGBLOB 4GB Stored off-page with minimal row overhead[8].

To define a VARBINARY column:

CREATE TABLE example (
    id INT PRIMARY KEY,
    data VARBINARY(10000)  -- Adjust size based on row limits
);

Always validate the maximum usable length using EXECUTE ... SELECT or schema checks, especially in multi-column tables[3][6].

Citations:


Review Directive: Verify and Document the Rationale for VARBINARY Column Size

The current implementation in src/spider/storage/mysql/mysql_stmt.hpp defines the value column as VARBINARY(999), which is substantially lower than the practical maximum of 65,535 bytes for a VARBINARY column (subject to row size and storage engine constraints). Please confirm whether this 999-byte limitation is intentional—perhaps based on expected data sizes or performance considerations—and consider if future requirements might benefit from a more generous allowance. If the choice is deliberate, it would be helpful to document the rationale inline. This consideration also applies to the similar column definitions at lines 70–73, 84–85, 144, and 151.

@sitaowang1998
sitaowang1998 deleted the db_size branch April 3, 2025 18:35
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.

Expand size of task input/output in database

1 participant