-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add support for different journal modes #4272
Conversation
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Signed-off-by: Jonas Franz <info@jonasfranz.software>
@@ -64,7 +64,7 @@ func InitIssueIndexer(populateIndexer func() error) { | |||
log.Fatal(4, "InitIssuesIndexer: create index, %v", err) | |||
} | |||
if err = populateIndexer(); err != nil { | |||
log.Fatal(4, "InitIssueIndexer: populate index, %v", err) | |||
//log.Fatal(4, "InitIssueIndexer: populate index, %v", err) |
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.
why comment this line?
@JonasFranzDEV Since that, could you enable |
Codecov Report
@@ Coverage Diff @@
## master #4272 +/- ##
==========================================
+ Coverage 19.97% 20.09% +0.11%
==========================================
Files 153 153
Lines 30524 30697 +173
==========================================
+ Hits 6097 6168 +71
- Misses 23513 23587 +74
- Partials 914 942 +28
Continue to review full report at Codecov.
|
custom/conf/app.ini.sample
Outdated
@@ -213,6 +213,8 @@ SSL_MODE = disable | |||
PATH = data/gitea.db | |||
; For "sqlite3" only. Query timeout | |||
SQLITE_TIMEOUT = 500 | |||
; For "sqlite3" only. Journal mode | |||
JOURNAL_MODE = WLA |
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.
@@ -129,6 +129,9 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. | |||
- `PASSWD`: **\<empty\>**: Database user password. Use \`your password\` for quoting if you use special characters in the password. | |||
- `SSL_MODE`: **disable**: For PostgreSQL only. | |||
- `PATH`: **data/gitea.db**: For SQLite3 only, the database file path. | |||
- `JOURNAL_MODE` **WLA**: For SQLite3 only, the journal mode. Use `DELETE` mode if you're running Gitea on a network file system |
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.
Same
@@ -129,6 +129,9 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. | |||
- `PASSWD`: **\<empty\>**: Database user password. Use \`your password\` for quoting if you use special characters in the password. | |||
- `SSL_MODE`: **disable**: For PostgreSQL only. | |||
- `PATH`: **data/gitea.db**: For SQLite3 only, the database file path. | |||
- `JOURNAL_MODE` **WLA**: For SQLite3 only, the journal mode. Use `DELETE` mode if you're running Gitea on a network file system | |||
or your operating system does not support VFS. Please checkout the [WAL documentation](https://www.sqlite.org/wal.html) to learn more. WLA |
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.
Same
Info about journal mode should be also added in admin settings display page |
The wal mode maybe an enforce mode not an option. |
Upgrade to latest go-sqlite3 because WAL is only supported with newer versions Signed-off-by: Jonas Franz <info@jonasfranz.software>
@JonasFranzDEV I've made the changes above and put them in a PR for you to be able to merge them into this PR: jonasfranz#2 |
Some files are missing in the last commit (c58e2c5) e.g. In addition, I think the database connection need be closed before Gitea exits. Otherwise, https://www.sqlite.org/wal.html#avoiding_excessively_large_wal_files
https://www.sqlite.org/tempfiles.html#write_ahead_log_wal_files
But I don't know why it hasn't been deleted or reset to 0KB. |
I've tried it locally and it does not improve the tests at any point. I think I should close this PR since it does not offer benefits to the user. Also setting max open connections to 1 results in the test hanging up. |
Fixes #2040 (partially)
Add the ability to set the journal mode used by SQLite3. The new default journal mode is WAL, since it produces more less database locked errors (nearly no errors).
Learn more about WAL: https://www.sqlite.org/wal.html
mattn/go-sqlite3#569 (comment)
Maybe should we also add
SetMaxOpenConnection(1)
. But I'm not sure about that.