Skip to content

Enable WAL to improve write performance and add db logger#137

Merged
dkhalife merged 1 commit intomainfrom
codex/enable-verbose-logging-and-wal-mode
Jul 7, 2025
Merged

Enable WAL to improve write performance and add db logger#137
dkhalife merged 1 commit intomainfrom
codex/enable-verbose-logging-and-wal-mode

Conversation

@dkhalife
Copy link
Owner

@dkhalife dkhalife commented Jul 7, 2025

Summary

  • enable verbose GORM logging
  • switch DB initialization to WAL and add busy timeout
  • use the same DB setup for tests
  • add a concurrency test to ensure updates work under contention
  • set GORM logger level from app config and disable colors

Testing

  • go test ./...

https://chatgpt.com/codex/tasks/task_e_686b37e1f23c832aa720cb583b5df093

Copilot AI review requested due to automatic review settings July 7, 2025 04:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances SQLite handling by centralizing database setup, configuring WAL mode with a busy timeout, and adding a concurrent-creation test.

  • Switches test database initialization to use NewDatabase with uniform config
  • Implements verbose GORM logging, WAL journal mode, and a 5000ms busy timeout in NewDatabase
  • Adds TestConcurrentCreateTask to verify concurrent task creation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/utils/test/database.go Replaced direct GORM open with dbutil.NewDatabase; missing fmt import
internal/utils/database/database.go Introduced NewDatabase method with configurable log level, WAL, and busy timeout
internal/repos/task/concurrency_test.go Added a concurrency test suite for creating tasks under contention
Comments suppressed due to low confidence (2)

internal/repos/task/concurrency_test.go:31

  • [nitpick] The PR description mentions testing concurrent updates, but this test only covers task creation. Consider adding scenarios for concurrent updates or adjusting the PR description to match the implemented test.
func (s *TaskConcurrencyTestSuite) TestConcurrentCreateTask() {

internal/utils/test/database.go:23

  • fmt.Sprintf is used but the fmt package is not imported, which will cause a compile error. Add import "fmt".
	suite.dbFilePath = fmt.Sprintf("%s/testdb_%d.db", os.TempDir(), time.Now().UnixNano())

@codecov
Copy link

codecov bot commented Jul 7, 2025

Codecov Report

Attention: Patch coverage is 46.87500% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/utils/database/database.go 43.33% 14 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@dkhalife dkhalife changed the title Improve SQLite handling Enable WAL to improve write performance and add db logger Jul 7, 2025
@dkhalife dkhalife merged commit 3e9dbe5 into main Jul 7, 2025
5 checks passed
@dkhalife dkhalife deleted the codex/enable-verbose-logging-and-wal-mode branch July 7, 2025 04:04
dkhalife added a commit that referenced this pull request Oct 5, 2025
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants