mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
ctdbd: Fix updating of hot keys in database statistics
Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit fde4b4db5a57f75c5efa5647c309f33e0d5a68f3)
This commit is contained in:
parent
d8fc36781c
commit
054d8727ed
@ -658,7 +658,7 @@ ctdb_defer_pinned_down_request(struct ctdb_context *ctdb, struct ctdb_db_context
|
||||
static void
|
||||
ctdb_update_db_stat_hot_keys(struct ctdb_db_context *ctdb_db, TDB_DATA key, int hopcount)
|
||||
{
|
||||
int i;
|
||||
int i, id;
|
||||
|
||||
/* smallest value is always at index 0 */
|
||||
if (hopcount <= ctdb_db->statistics.hot_keys[0].count) {
|
||||
@ -681,16 +681,22 @@ ctdb_update_db_stat_hot_keys(struct ctdb_db_context *ctdb_db, TDB_DATA key, int
|
||||
goto sort_keys;
|
||||
}
|
||||
|
||||
if (ctdb_db->statistics.hot_keys[0].key.dptr != NULL) {
|
||||
talloc_free(ctdb_db->statistics.hot_keys[0].key.dptr);
|
||||
if (ctdb_db->statistics.num_hot_keys < MAX_HOT_KEYS) {
|
||||
id = ctdb_db->statistics.num_hot_keys;
|
||||
ctdb_db->statistics.num_hot_keys++;
|
||||
} else {
|
||||
id = 0;
|
||||
}
|
||||
ctdb_db->statistics.hot_keys[0].key.dsize = key.dsize;
|
||||
ctdb_db->statistics.hot_keys[0].key.dptr = talloc_memdup(ctdb_db, key.dptr, key.dsize);
|
||||
ctdb_db->statistics.hot_keys[0].count = hopcount;
|
||||
|
||||
if (ctdb_db->statistics.hot_keys[id].key.dptr != NULL) {
|
||||
talloc_free(ctdb_db->statistics.hot_keys[id].key.dptr);
|
||||
}
|
||||
ctdb_db->statistics.hot_keys[id].key.dsize = key.dsize;
|
||||
ctdb_db->statistics.hot_keys[id].key.dptr = talloc_memdup(ctdb_db, key.dptr, key.dsize);
|
||||
ctdb_db->statistics.hot_keys[id].count = hopcount;
|
||||
|
||||
sort_keys:
|
||||
for (i = 2; i < MAX_HOT_KEYS; i++) {
|
||||
for (i = 1; i < MAX_HOT_KEYS; i++) {
|
||||
if (ctdb_db->statistics.hot_keys[i].count < ctdb_db->statistics.hot_keys[0].count) {
|
||||
hopcount = ctdb_db->statistics.hot_keys[i].count;
|
||||
ctdb_db->statistics.hot_keys[i].count = ctdb_db->statistics.hot_keys[0].count;
|
||||
|
Loading…
x
Reference in New Issue
Block a user