[PR #1460] [MERGED] Fix nginx-ui issue 1455 #1297

Closed
opened 2026-02-26 12:11:07 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/0xJacky/nginx-ui/pull/1460
Author: @0xJacky
Created: 11/29/2025
Status: Merged
Merged: 11/29/2025
Merged by: @0xJacky

Base: devHead: cursor/fix-nginx-ui-issue-1455-gpt-5.1-codex-high-079c


📝 Commits (1)

  • 8e9fa7d Refactor: Improve incremental log indexing logic

📊 Changes

2 files changed (+151 additions, -10 deletions)

View changed files

📝 internal/cron/incremental_indexing.go (+43 -10)
internal/cron/incremental_indexing_test.go (+108 -0)

📄 Description

Fixes #1455 by using per-file persisted metadata for incremental indexing decisions to prevent unnecessary re-indexing caused by aggregated log sizes.

The previous incremental indexing logic could incorrectly trigger re-indexing due to log.LastSize being an aggregated value across rotated log files (e.g., access.log and access.log.1). This led to false positives where the system believed a file had shrunk or grown, causing infinite rebuilds. This PR injects the actual PersistenceManager to use accurate per-file metadata for LastModified and LastSize, ensuring indexing only occurs when truly needed. A fallback mechanism is also included for cases where persistence data isn't available, clamping the LastSize to prevent similar issues.


Open in Cursor Open in Web


Note

Switch incremental indexing to per-file persisted metadata with a safe fallback, add rotation-aware doc count updates, and include unit tests.

  • Incremental indexing logic:
    • Use persistence (logIndexProvider) to decide indexing via per-file metadata (GetLogIndex/NeedsIndexing).
    • Fallback path clamps aggregated LastSize, handles never-indexed files, and refines change detection.
    • Pass persistence from LogFileManager into needsIncrementalIndexing and job loop.
  • Indexing execution (queueIncrementalIndexing):
    • Detect log rotation by size decrease; reset document count on rotation, otherwise accumulate.
    • Persist indexing metadata (SaveIndexMetadata) and manage statuses via persistence-backed setFileIndexStatus with simple queue ordering.
  • Tests:
    • Add internal/cron/incremental_indexing_test.go with stub provider covering unchanged file skip and growth detection.

Written by Cursor Bugbot for commit 8e9fa7d0e0. This will update automatically on new commits. Configure here.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/0xJacky/nginx-ui/pull/1460 **Author:** [@0xJacky](https://github.com/0xJacky) **Created:** 11/29/2025 **Status:** ✅ Merged **Merged:** 11/29/2025 **Merged by:** [@0xJacky](https://github.com/0xJacky) **Base:** `dev` ← **Head:** `cursor/fix-nginx-ui-issue-1455-gpt-5.1-codex-high-079c` --- ### 📝 Commits (1) - [`8e9fa7d`](https://github.com/0xJacky/nginx-ui/commit/8e9fa7d0e0cc776648f225cdec097d4cfe7ea00b) Refactor: Improve incremental log indexing logic ### 📊 Changes **2 files changed** (+151 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `internal/cron/incremental_indexing.go` (+43 -10) ➕ `internal/cron/incremental_indexing_test.go` (+108 -0) </details> ### 📄 Description Fixes #1455 by using per-file persisted metadata for incremental indexing decisions to prevent unnecessary re-indexing caused by aggregated log sizes. The previous incremental indexing logic could incorrectly trigger re-indexing due to `log.LastSize` being an aggregated value across rotated log files (e.g., `access.log` and `access.log.1`). This led to false positives where the system believed a file had shrunk or grown, causing infinite rebuilds. This PR injects the actual `PersistenceManager` to use accurate per-file metadata for `LastModified` and `LastSize`, ensuring indexing only occurs when truly needed. A fallback mechanism is also included for cases where persistence data isn't available, clamping the `LastSize` to prevent similar issues. --- <a href="https://cursor.com/background-agent?bcId=bc-98a269d0-ef88-4297-bfa0-5c088ce6e234"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-98a269d0-ef88-4297-bfa0-5c088ce6e234"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Switch incremental indexing to per-file persisted metadata with a safe fallback, add rotation-aware doc count updates, and include unit tests. > > - **Incremental indexing logic**: > - Use persistence (`logIndexProvider`) to decide indexing via per-file metadata (`GetLogIndex`/`NeedsIndexing`). > - Fallback path clamps aggregated `LastSize`, handles never-indexed files, and refines change detection. > - Pass persistence from `LogFileManager` into `needsIncrementalIndexing` and job loop. > - **Indexing execution** (`queueIncrementalIndexing`): > - Detect log rotation by size decrease; reset document count on rotation, otherwise accumulate. > - Persist indexing metadata (`SaveIndexMetadata`) and manage statuses via persistence-backed `setFileIndexStatus` with simple queue ordering. > - **Tests**: > - Add `internal/cron/incremental_indexing_test.go` with stub provider covering unchanged file skip and growth detection. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8e9fa7d0e0cc776648f225cdec097d4cfe7ea00b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 12:11:07 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#1297
No description provided.