aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/salis-v1/arch.j2.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/arch/salis-v1/arch.j2.c b/arch/salis-v1/arch.j2.c
index aaa5284..f2b9990 100644
--- a/arch/salis-v1/arch.j2.c
+++ b/arch/salis-v1/arch.j2.c
@@ -773,7 +773,7 @@ void arch_push_data_header() {
assert(g_sim_data);
const char *sql = (
- "create table data("
+ "create table trend("
"step int not null, "
{% for i in range(args.cores) %}
"cycl_{{ i }} int not null, "
@@ -791,13 +791,23 @@ void arch_push_data_header() {
");"
);
- {% set sql_call %}sqlite3_exec(g_sim_data, sql, NULL, NULL, NULL){% endset %}
+ g_info("Generating 'trend' table in SQLite database");
- {% if not args.optimized %}
- assert({{ sql_call }} == 0);
- {% else %}
- {{ sql_call }};
- {% endif %}
+ int sql_res;
+ char *sql_err;
+
+ // Only handle busy database errors
+ // Application should fail on all other error conditions
+ while ((sql_res = sqlite3_exec(g_sim_data, sql, NULL, NULL, &sql_err)) == SQLITE_BUSY) {
+ g_warn("Busy SQLite database returned error '%d' with message:", sql_res);
+ g_warn(sql_err);
+
+ sqlite3_free(sql_err);
+
+ g_info("Will retry query...");
+ }
+
+ assert(sql_res == 0);
}
void arch_push_data_line() {
@@ -835,7 +845,7 @@ void arch_push_data_line() {
asprintf(
&sql,
- "insert into data ("
+ "insert into trend ("
"step, "
{% for i in range(args.cores) %}
"cycl_{{ i }}, "
@@ -876,13 +886,23 @@ void arch_push_data_line() {
{% endfor %}
);
- {% set sql_call %}sqlite3_exec(g_sim_data, sql, NULL, NULL, NULL){% endset %}
+ g_info("Pushing row to 'trend' table in SQLite database");
- {% if not args.optimized %}
- assert({{ sql_call }} == 0);
- {% else %}
- {{ sql_call }};
- {% endif %}
+ int sql_res;
+ char *sql_err;
+
+ // Only handle busy database errors
+ // Application should fail on all other error conditions
+ while ((sql_res = sqlite3_exec(g_sim_data, sql, NULL, NULL, &sql_err)) == SQLITE_BUSY) {
+ g_warn("Busy SQLite database returned error '%d' with message:", sql_res);
+ g_warn(sql_err);
+
+ sqlite3_free(sql_err);
+
+ g_info("Will retry query...");
+ }
+
+ assert(sql_res == 0);
// Free query string returned by 'asprintf()'
free(sql);