Skip to content

Commit f0c2c9c

Browse files
committed
in_tail: new 'db.wal' option
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
1 parent e312ef1 commit f0c2c9c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

plugins/in_tail/tail.c

+7
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,13 @@ static struct flb_config_map config_map[] = {
604604
"set exclusive locking mode, increase performance but don't allow "
605605
"external connections to the database file."
606606
},
607+
{
608+
FLB_CONFIG_MAP_BOOL, "db.wal", "on",
609+
0, FLB_TRUE, offsetof(struct flb_tail_config, db_wal),
610+
"enable or disable Work Ahead Logging mechanism (WAL). Enabling WAL "
611+
"provides higher performance. Note that WAL is not compatible with "
612+
"shared network file systems."
613+
},
607614
#endif
608615

609616
/* Multiline Options */

plugins/in_tail/tail_config.h

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct flb_tail_config {
8686
struct flb_sqldb *db;
8787
int db_sync;
8888
int db_locking;
89+
int db_wal;
8990
sqlite3_stmt *stmt_get_file;
9091
sqlite3_stmt *stmt_insert_file;
9192
sqlite3_stmt *stmt_delete_file;

plugins/in_tail/tail_db.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ struct flb_sqldb *flb_tail_db_open(const char *path,
6767
}
6868
}
6969

70-
ret = flb_sqldb_query(db, SQL_PRAGMA_JOURNAL_MODE, NULL, NULL);
71-
if (ret != FLB_OK) {
72-
flb_plg_error(ctx->ins, "db: could not set pragma 'journal_mode'");
73-
flb_sqldb_close(db);
74-
return NULL;
75-
}
76-
7770
if (ctx->db_locking == FLB_TRUE) {
7871
ret = flb_sqldb_query(db, SQL_PRAGMA_LOCKING_MODE, NULL, NULL);
7972
if (ret != FLB_OK) {
@@ -83,6 +76,15 @@ struct flb_sqldb *flb_tail_db_open(const char *path,
8376
}
8477
}
8578

79+
if (ctx->db_wal) {
80+
ret = flb_sqldb_query(db, SQL_PRAGMA_JOURNAL_MODE, NULL, NULL);
81+
if (ret != FLB_OK) {
82+
flb_plg_error(ctx->ins, "db: could not set pragma 'journal_mode'");
83+
flb_sqldb_close(db);
84+
return NULL;
85+
}
86+
}
87+
8688
return db;
8789
}
8890

0 commit comments

Comments
 (0)