Skip to content

Commit

Permalink
in_tail: new 'db.wal' option
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Mar 15, 2021
1 parent e312ef1 commit f0c2c9c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
7 changes: 7 additions & 0 deletions plugins/in_tail/tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@ static struct flb_config_map config_map[] = {
"set exclusive locking mode, increase performance but don't allow "
"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 "
"provides higher performance. Note that WAL is not compatible with "
"shared network file systems."
},
#endif

/* Multiline Options */
Expand Down
1 change: 1 addition & 0 deletions plugins/in_tail/tail_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct flb_tail_config {
struct flb_sqldb *db;
int db_sync;
int db_locking;
int db_wal;
sqlite3_stmt *stmt_get_file;
sqlite3_stmt *stmt_insert_file;
sqlite3_stmt *stmt_delete_file;
Expand Down
16 changes: 9 additions & 7 deletions plugins/in_tail/tail_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ struct flb_sqldb *flb_tail_db_open(const char *path,
}
}

ret = flb_sqldb_query(db, SQL_PRAGMA_JOURNAL_MODE, NULL, NULL);
if (ret != FLB_OK) {
flb_plg_error(ctx->ins, "db: could not set pragma 'journal_mode'");
flb_sqldb_close(db);
return NULL;
}

if (ctx->db_locking == FLB_TRUE) {
ret = flb_sqldb_query(db, SQL_PRAGMA_LOCKING_MODE, NULL, NULL);
if (ret != FLB_OK) {
Expand All @@ -83,6 +76,15 @@ 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 (ret != FLB_OK) {
flb_plg_error(ctx->ins, "db: could not set pragma 'journal_mode'");
flb_sqldb_close(db);
return NULL;
}
}

return db;
}

Expand Down

0 comments on commit f0c2c9c

Please sign in to comment.