Skip to content

Conversation

@OSXLich-Doug
Copy link
Contributor

@OSXLich-Doug OSXLich-Doug commented Sep 22, 2025

Important

Adds a feature for periodic database maintenance in Lich, performing a VACUUM operation every 6 months if due, with error handling and logging.

  • Behavior:
    • Adds Lich.db_vacuum_if_due! in lib/lich.rb to perform VACUUM on the database if due (every 6 months).
    • Integrates Lich.db_vacuum_if_due! into start_wrap_thread in lib/games.rb to run on startup.
    • Handles SQLite3 busy exceptions by retrying after a short sleep.
    • Logs errors and skips VACUUM if the database is busy or lock is held.
  • 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 last timestamp.
    • Lich.db_vacuum_if_due!: Attempts to perform VACUUM if maintenance is due, with file locking.
  • Misc:
    • Adds logging for maintenance actions and errors in lib/lich.rb.

This description was created by Ellipsis for 325405a. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 135 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 draft 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% <= threshold 50% 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% <= threshold 50% 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% <= threshold 50% 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% <= threshold 50% None

Workflow ID: wflow_atrRUDgMON8UDGhv

You can customize Ellipsis 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
github-actions bot added a commit that referenced this pull request Dec 3, 2025
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants