Skip to content

feat: set default retry time to 3 for dal init#390

Merged
killagu merged 2 commits intomasterfrom
feat/default_try_time
Jan 7, 2026
Merged

feat: set default retry time to 3 for dal init#390
killagu merged 2 commits intomasterfrom
feat/default_try_time

Conversation

@killagu
Copy link
Contributor

@killagu killagu commented Jan 7, 2026

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Summary by CodeRabbit

  • Bug Fixes

    • Standardized MySQL data source connection retry behavior to use a consistent default retry count when not explicitly configured.
  • Tests

    • Updated tests to verify behavior when retries are disabled, ensuring connection initialization fails immediately in that case.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

Replaces undefined initRetryTimes with a concrete default by adding DEFAULT_RETRY_TIMES = 3 and using initRetryTimes ?? DEFAULT_RETRY_TIMES in MySqlDataSource; tests updated to pass initRetryTimes: 0 to exercise no-retry behavior.

Changes

Cohort / File(s) Summary
MySQL Connection Retry Defaults
core/dal-runtime/src/MySqlDataSource.ts
Added DEFAULT_RETRY_TIMES = 3 constant and changed constructor to set #initRetryTimes via nullish coalescing (initRetryTimes ?? DEFAULT_RETRY_TIMES) to ensure a concrete default when not provided.
Tests — retry behavior
core/dal-runtime/test/DataSource.test.ts
Updated test to construct MysqlDataSource with initRetryTimes: 0, making initialization fail immediately (no retries) and validating expected query/initSql interactions.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly Related PRs

Poem

🐰 A little default hops into the code,
Three gentle tries along the connection road,
Tests set zero, to skip the repeat,
The rabbit cheers — concise and neat! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: introducing a default retry time of 3 for DAL initialization, which matches the code changes that add DEFAULT_RETRY_TIMES constant and update the MysqlDataSource constructor logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom Pre-merge Checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e975992 and 3c65dd4.

📒 Files selected for processing (1)
  • core/dal-runtime/test/DataSource.test.ts
🧰 Additional context used
🧬 Code graph analysis (1)
core/dal-runtime/test/DataSource.test.ts (1)
core/dal-runtime/src/MySqlDataSource.ts (1)
  • MysqlDataSource (28-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Analyze (typescript)
🔇 Additional comments (1)
core/dal-runtime/test/DataSource.test.ts (1)

35-35: LGTM! Correct test update to preserve original behavior.

The explicit initRetryTimes: 0 ensures this test continues to verify immediate failure without retries, now that the default retry count is 3.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @killagu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of the Data Access Layer by implementing a default retry mechanism for MySQL data source initialization. By setting a standard retry count, the system can better handle transient connection issues during startup, ensuring more reliable service availability without requiring explicit configuration for every instance.

Highlights

  • Default Retry Time: A default retry time of 3 has been introduced for the Data Access Layer (DAL) initialization process.
  • MySQL Data Source: The MysqlDataSource constructor now utilizes this new default retry time for initRetryTimes if no specific value is provided.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly implements a default retry count of 3 for the DAL initialization, which improves robustness. The change is well-implemented.

I have one suggestion to tighten the type definition for #initRetryTimes now that it's guaranteed to have a value.

Additionally, I recommend adding a unit test to cover this new default behavior, as the test checklist in the PR description is currently not marked as complete.

this.forkDb = forkDb;
this.initSql = initSql ?? 'SELECT 1 + 1';
this.#initRetryTimes = initRetryTimes;
this.#initRetryTimes = initRetryTimes ?? DEFAULT_RETRY_TIMES;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

With this change, this.#initRetryTimes is guaranteed to be a number. To improve type safety and reflect this guarantee in the type system, please update its declaration on line 35 to be non-optional.

Change from:

readonly #initRetryTimes?: number;

To:

readonly #initRetryTimes: number;

Copy link

@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

🧹 Nitpick comments (1)
core/dal-runtime/src/MySqlDataSource.ts (1)

35-35: Consider removing the optional marker from the type.

Since #initRetryTimes is now always assigned a value (via the default at line 45), the optional ? is no longer accurate. Removing it improves type safety and eliminates the need for the !this.#initRetryTimes check in line 67.

🔎 Proposed fix
-  readonly #initRetryTimes?: number;
+  readonly #initRetryTimes: number;

If applied, line 67's condition can also be simplified:

-      if (!this.#initRetryTimes || tryTimes >= this.#initRetryTimes) {
+      if (tryTimes >= this.#initRetryTimes) {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9edf6d0 and e975992.

📒 Files selected for processing (1)
  • core/dal-runtime/src/MySqlDataSource.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-ubuntu (16)
🔇 Additional comments (2)
core/dal-runtime/src/MySqlDataSource.ts (2)

22-23: LGTM!

Good use of a named constant for the default retry value. This improves maintainability and makes the magic number self-documenting.


44-45: LGTM!

Correct use of nullish coalescing (??) to apply the default. This preserves explicit 0 values (if a caller wants to disable retries) while defaulting undefined to 3.

@killagu killagu merged commit afde48c into master Jan 7, 2026
12 checks passed
@killagu killagu deleted the feat/default_try_time branch January 7, 2026 05:42
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