Skip to content

Commit 966abb9

Browse files
srivarun91togas82
andauthored
AER-6846 - Abandon secondary index population on system memory stop-writes and indexes-memory-budget for in-memory indexes.
Co-authored-by: Suresh Togas <[email protected]>
1 parent 81e63e0 commit 966abb9

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

as/include/base/datamodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ typedef struct as_namespace_s {
864864

865865
bool stop_writes;
866866
bool hwm_breached;
867+
bool memory_breached; // stop-writes-sys-memory-pct or indexes-memory-budget
867868

868869
uint64_t non_expirable_objects;
869870

as/include/sindex/sindex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ typedef struct as_sindex_s {
105105

106106
bool readable; // false while building sindex
107107
bool dropped;
108+
bool error;
108109
uint32_t n_jobs;
109110

110111
uint64_t keys_per_bval;

as/src/base/nsup.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,9 +933,11 @@ eval_stop_writes(as_namespace* ns, bool cold_starting)
933933
char* at = reasons;
934934

935935
uint32_t cfg_pct = as_load_uint32(&ns->stop_writes_sys_memory_pct);
936+
bool memory_breached = false;
936937

937938
// Note - not >= since sys_memory_pct is rounded up, not down.
938939
if (cfg_pct != 0 && sys_memory_pct > cfg_pct) {
940+
memory_breached = true;
939941
at = stpcpy(at, "sys-memory & ");
940942
}
941943

@@ -944,9 +946,12 @@ eval_stop_writes(as_namespace* ns, bool cold_starting)
944946
uint64_t ixs_memory_budget = as_load_uint64(&ns->indexes_memory_budget);
945947

946948
if (ixs_memory_budget != 0 && ixs_sz > ixs_memory_budget) {
949+
memory_breached = true;
947950
at = stpcpy(at, "indexes-memory & ");
948951
}
949952

953+
ns->memory_breached = memory_breached;
954+
950955
// Note - configured value 0 automatically switches this off. Also, not <=
951956
// because avail vs. used, though data_avail_pct is rounded down.
952957
if (data_avail_pct < ns->storage_stop_writes_avail_pct) {

as/src/sindex/populate.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,15 @@ populate_reduce_cb(as_index_ref* r_ref, void* udata)
419419
return false;
420420
}
421421

422+
if (! as_namespace_sindex_persisted(ns) && ns->memory_breached) {
423+
cf_warning(AS_SINDEX, "{%s} populating sindex %s - aborted due to memory limit breach",
424+
ns->name, si->iname);
425+
si->error = true; // an error, once set, can't be cleared until restart
426+
*cbi->p_aborted = true;
427+
as_record_done(r_ref, ns);
428+
return false;
429+
}
430+
422431
if (++cbi->n_reduced == PROGRESS_RESOLUTION) {
423432
cbi->n_reduced = 0;
424433

as/src/sindex/sindex.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,10 @@ as_sindex_list_str(const as_namespace* ns, bool b64, cf_dyn_buf* db)
552552
}
553553
}
554554

555-
if (si->readable) {
555+
if (si->error) {
556+
cf_dyn_buf_append_string(db, ":state=ERROR");
557+
}
558+
else if (si->readable) {
556559
cf_dyn_buf_append_string(db, ":state=RW");
557560
}
558561
else {

0 commit comments

Comments
 (0)