-
Notifications
You must be signed in to change notification settings - Fork 32
feat(all): add simplified DB maintenance #991
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
Open
OSXLich-Doug
wants to merge
1
commit into
main
Choose a base branch
from
simplified_db_maintenance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
Looks good to me! 👍
Reviewed everything up to 325405a in 2 minutes and 55 seconds. Click for details.
- Reviewed
135lines of code in2files - Skipped
0files when reviewing. - Skipped posting
6draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. lib/lich.rb:23
- Draft comment:
Wrap multiple DB update statements in a transaction in db_maint_set! to ensure atomicity. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While transactions can help with atomicity, the operations here are already atomic individually. The CREATE TABLE is idempotent, and INSERT OR REPLACE is atomic. The two inserts are related but partial completion wouldn't leave the DB in an invalid state - having just the timestamp or just the note would be fine. The retry on busy already handles concurrency. I could be underestimating the importance of the two inserts being done together. Maybe there are scenarios where having mismatched timestamp/note pairs would cause issues. The code already handles the key failure modes with busy retry. The inserts are independent enough that strict atomicity isn't critical. The comment seems to be suggesting a "best practice" without clear benefit. The comment should be deleted as it suggests additional complexity without demonstrating clear benefit or risk.
2. lib/lich.rb:63
- Draft comment:
The lock acquisition loop uses a busy-wait (sleep 0.1); consider adding a maximum retry limit or configurable timeout to avoid potential infinite loops. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
3. lib/lich.rb:94
- Draft comment:
Rescuing SQLite3::BusyException during the VACUUM call leads to quietly skipping maintenance; ensure this behavior is acceptable. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
4. lib/lich.rb:12
- Draft comment:
Infinite retry loops on SQLite3::BusyException (e.g., in db_maint_last_at and elsewhere) could risk blocking; consider a maximum retry count. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 30% vs. threshold = 50% The comment raises a legitimate concern about potential infinite loops. While SQLite busy errors are typically transient, having no upper bound on retries could theoretically cause a hang. However, this is a maintenance utility that runs occasionally, not critical path code. The simple retry pattern makes the code more readable and matches the file's "simple + safe" comment. Adding retry limits would make the code more complex. I may be underestimating the impact of a potential hang. Even maintenance code should have safeguards against infinite loops. While the concern is valid, the current simple approach aligns with the module's stated goals of being "minimal" and "simple + safe". The risk of an actual infinite loop is low given SQLite's reliability. While the comment raises a valid concern, the current simple retry approach is a reasonable tradeoff for maintenance code that prioritizes simplicity. The comment should be removed as it doesn't justify the added complexity of retry limits.
5. lib/lich.rb:6
- Draft comment:
File.flock usage (in db_maint_lock_path and its consumption) may behave differently on non-Unix platforms; ensure or document platform compatibility. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
6. lib/games.rb:213
- Draft comment:
The call to Lich.db_vacuum_if_due! is wrapped in a rescue that only logs errors; ensure that silently skipping maintenance on failure is acceptable. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
Workflow ID: wflow_atrRUDgMON8UDGhv
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
OSXLich-Doug
added a commit
to Lich5/prod-candidate-RP-history
that referenced
this pull request
Oct 11, 2025
Upstream PR: #991 Source repo: elanthia-online/lich-5 Source URL: elanthia-online/lich-5#991
OSXLich-Doug
added a commit
to Lich5/prod-candidate-RP-history
that referenced
this pull request
Oct 18, 2025
Upstream PR: #991 Source repo: elanthia-online/lich-5 Source URL: elanthia-online/lich-5#991 <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Adds a feature to perform database vacuum maintenance if due, with error handling and logging, triggered at startup in `lib/games.rb`. > > - **Behavior**: > - Adds `Lich.db_vacuum_if_due!` in `lib/lich.rb` to perform a database vacuum if due, based on a 6-month interval. > - Logs errors and skips vacuum if the database is busy or if another process holds the lock. > - Triggered at startup in `start_wrap_thread` in `lib/games.rb`. > - **Functions**: > - `Lich.db_maint_lock_path`: Returns the path for the maintenance lock file. > - `Lich.db_maint_last_at`: Retrieves the last maintenance timestamp from the database. > - `Lich.db_maint_set!`: Updates the last maintenance timestamp and note in the database. > - `Lich.db_maint_due?`: Checks if maintenance is due based on the specified interval. > - `Lich.db_vacuum_if_due!`: Attempts to vacuum the database if due, with file locking and error handling. > - **Logging**: > - Logs various errors and states, such as lock acquisition failures and vacuum operation results. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=Lich5%2Fng-betalich&utm_source=github&utm_medium=referral)<sup> for b9a4986. You can [customize](https://app.ellipsis.dev/Lich5/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
OSXLich-Doug
added a commit
to Lich5/ng-betalich
that referenced
this pull request
Oct 23, 2025
Upstream PR: #991 Source repo: elanthia-online/lich-5 Source URL: elanthia-online/lich-5#991
OSXLich-Doug
pushed a commit
that referenced
this pull request
Dec 4, 2025
Lich v5.13.0-beta.1 (2025-12-03) ### Features (general) * Refocus Frontend ([#960](#960)) * add simplified DB maintenance ([#991](#991)) * TextStripper module support for XML, HTML, Markdown ([#1055](#1055)) * Ruby Memory Releaser module ([#1066](#1066)) ### Features (gs) * add creature module, including Hinterwilds creatures ([#1002](#1002)) * Creature module combat tracking ([#1003](#1003)) * add Injured class for checking ability to perform actions ([#1035](#1035)) ### Bug Fixes (general) * map dijkstra optimization ([#1061](#1061)) * update.rb keep script/data file incase of error on update ([#1070](#1070)) ### Bug Fixes (gs) * Infomon additional CHE resign regex ([#1067](#1067)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please#release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Release 5.13.0-beta.1 with new modules, features, and bug fixes, updating version in multiple files. > > - **Version Update**: > - Update version to `5.13.0-beta.1` in `.release-please-manifest.json`, `R4LGTK3.iss`, and `lib/version.rb`. > - **Features**: > - Add simplified DB maintenance. > - Introduce Ruby Memory Releaser module. > - Add TextStripper module for XML, HTML, Markdown. > - Add creature module with Hinterwilds creatures and combat tracking. > - Add `Injured` class for action ability checks. > - **Bug Fixes**: > - Optimize map Dijkstra algorithm. > - Preserve script/data file on update error in `update.rb`. > - Add Infomon CHE resign regex. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=elanthia-online%2Flich-5&utm_source=github&utm_medium=referral)<sup> for 64e4182. You can [customize](https://app.ellipsis.dev/elanthia-online/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> <!-- FORMATTER:v1 sha=95f8f517411f9058bc92706310677db8cbba97fbd296bc853f2181274cb0e8bb mode=beta --> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important
Adds a feature for periodic database maintenance in Lich, performing a VACUUM operation every 6 months if due, with error handling and logging.
Lich.db_vacuum_if_due!inlib/lich.rbto perform VACUUM on the database if due (every 6 months).Lich.db_vacuum_if_due!intostart_wrap_threadinlib/games.rbto run on startup.Lich.db_maint_lock_path: Returns the path for the maintenance lock file.Lich.db_maint_last_at: Retrieves the last maintenance timestamp from the database.Lich.db_maint_set!: Updates the last maintenance timestamp and note in the database.Lich.db_maint_due?: Checks if maintenance is due based on the last timestamp.Lich.db_vacuum_if_due!: Attempts to perform VACUUM if maintenance is due, with file locking.lib/lich.rb.This description was created by
for 325405a. You can customize this summary. It will automatically update as commits are pushed.