Skip to content
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

tail: added configuration for journal mode in WAL #3239

Merged
merged 4 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/in_tail/tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,9 @@ static struct flb_config_map config_map[] = {
"external connections to the database file."
},
{
FLB_CONFIG_MAP_BOOL, "db.wal", "on",
0, FLB_TRUE, offsetof(struct flb_tail_config, db_wal),
"enable or disable Work Ahead Logging mechanism (WAL). Enabling WAL "
FLB_CONFIG_MAP_STR, "db.journal_mode", "WAL",
0, FLB_TRUE, offsetof(struct flb_tail_config, db_journal_mode),
"Option to provide WAL configuration for Work Ahead Logging mechanism (WAL). Enabling WAL "
"provides higher performance. Note that WAL is not compatible with "
"shared network file systems."
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/in_tail/tail_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct flb_tail_config {
struct flb_sqldb *db;
int db_sync;
int db_locking;
int db_wal;
struct flb_sqldb *db_journal_mode;
sqlite3_stmt *stmt_get_file;
sqlite3_stmt *stmt_insert_file;
sqlite3_stmt *stmt_delete_file;
Expand Down
8 changes: 5 additions & 3 deletions plugins/in_tail/tail_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ struct flb_sqldb *flb_tail_db_open(const char *path,
}
}

if (ctx->db_wal) {
ret = flb_sqldb_query(db, SQL_PRAGMA_JOURNAL_MODE, NULL, NULL);
if (ctx->db_journal_mode >= 0) {
snprintf(tmp, sizeof(tmp) - 1, SQL_PRAGMA_JOURNAL_MODE,
ctx->db_journal_mode);
ret = flb_sqldb_query(db, tmp, NULL, NULL);
if (ret != FLB_OK) {
flb_plg_error(ctx->ins, "db: could not set pragma 'journal_mode'");
flb_plg_error(ctx->ins, "db could not set pragma 'journal_mode'");
flb_sqldb_close(db);
return NULL;
}
Expand Down