summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/gfdb/gfdb_sqlite3.c
diff options
context:
space:
mode:
authorMilind Changire <mchangir@redhat.com>2016-11-13 10:52:03 +0530
committerDan Lambright <dlambrig@redhat.com>2016-11-28 08:51:36 -0800
commit1001a4f7705f991f3ae1611997cf01b341ac453a (patch)
treeb234f99220eebf640cd864f73ae4f2b848cac12e /libglusterfs/src/gfdb/gfdb_sqlite3.c
parent1b003694f24d82a946e0584213ccf399ba923d58 (diff)
cluster/tier: handle fast demotions
Demote files on priority if hi-watermark has been breached and continue to demote until the watermark drops below hi-watermark. Monitor watermark more frequently. Trigger demotion as soon as hi-watermark is breached. Add cluster.tier-query-limit option to limit number of files returned from the database query for every iteration of tier_migrate_using_query_file(). If watermark hasn't dropped below hi-watermark during the first iteration, the next iteration will be triggered approximately 1 second after tier_demote() returns to the main tiering loop. Update changetimerecorder xlator to handle query for emergency demote mode. Add tier-ctr-interface.h: Move tier and ctr interface specific macros and struct definition from libglusterfs/src/gfdb/gfdb_data_store.h to new header libglusterfs/src/tier-ctr-interface.h > Reviewed-on: http://review.gluster.org/15158 > Smoke: Gluster Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Reviewed-by: Dan Lambright <dlambrig@redhat.com> (cherry picked from commit 460016428cf27484c333227f534c2e2f73a37fb1) Change-Id: If56af78c6c81d37529b9b6e65ae606ba5c99a811 BUG: 1394482 Signed-off-by: Milind Changire <mchangir@redhat.com> Reviewed-on: http://review.gluster.org/15835 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'libglusterfs/src/gfdb/gfdb_sqlite3.c')
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c
index 04781be562a..ec7fe3965eb 100644
--- a/libglusterfs/src/gfdb/gfdb_sqlite3.c
+++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c
@@ -631,12 +631,15 @@ gf_get_basic_query_stmt (char **out_stmt)
* */
int
gf_sqlite3_find_all (void *db_conn, gf_query_callback_t query_callback,
- void *query_cbk_args)
+ void *query_cbk_args,
+ int query_limit)
{
int ret = -1;
char *query_str = NULL;
gf_sql_connection_t *sql_conn = db_conn;
sqlite3_stmt *prep_stmt = NULL;
+ char *limit_query = NULL;
+ char *query = NULL;
CHECK_SQL_CONN (sql_conn, out);
GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, query_callback, out);
@@ -646,12 +649,28 @@ gf_sqlite3_find_all (void *db_conn, gf_query_callback_t query_callback,
goto out;
}
- ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, query_str, -1,
+ query = query_str;
+
+ if (query_limit > 0) {
+ ret = gf_asprintf (&limit_query, "%s LIMIT %d",
+ query, query_limit);
+ if (ret < 0) {
+ gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
+ LG_MSG_QUERY_FAILED,
+ "Failed creating limit query statement");
+ limit_query = NULL;
+ goto out;
+ }
+
+ query = limit_query;
+ }
+
+ ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, query, -1,
&prep_stmt, 0);
if (ret != SQLITE_OK) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
- LG_MSG_PREPARE_FAILED, "Failed to prepare statement %s :"
- "%s", query_str,
+ LG_MSG_PREPARE_FAILED,
+ "Failed to prepare statement %s: %s", query,
sqlite3_errmsg (sql_conn->sqlite3_db_conn));
ret = -1;
goto out;
@@ -660,7 +679,7 @@ gf_sqlite3_find_all (void *db_conn, gf_query_callback_t query_callback,
ret = gf_sql_query_function (prep_stmt, query_callback, query_cbk_args);
if (ret) {
gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED,
- "Failed Query %s", query_str);
+ "Failed Query %s", query);
goto out;
}
@@ -668,6 +687,10 @@ gf_sqlite3_find_all (void *db_conn, gf_query_callback_t query_callback,
out:
sqlite3_finalize (prep_stmt);
GF_FREE (query_str);
+
+ if (limit_query)
+ GF_FREE (limit_query);
+
return ret;
}
@@ -1069,10 +1092,10 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn,
GF_COL_TB_WMSEC ") >= ? ) ) )"
" AND "
/*Second condition: For Reads
- * Files that have reaASCd wind time smaller than for_time
+ * Files that have read wind time smaller than for_time
* OR
* File that have read wind time greater than for_time,
- * but write_frequency less than freq_write_cnt*/
+ * but read_frequency less than freq_read_cnt*/
"( ((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + "
GF_COL_TB_RWMSEC ") < ? )"
" OR "