Skip to content

Commit

Permalink
ovsdb: Fix database statistics during the database replacement.
Browse files Browse the repository at this point in the history
The counter for the number of atoms has to be re-set to the number from
the new database, otherwise the value will be incorrect.  For example,
this is causing the atom counter doubling after online conversion of
a clustered database.

Miscounting may also lead to increased memory consumption by the
transaction history or otherwise too aggressive transaction history
sweep.

Fixes: 317b1bf ("ovsdb: Don't let transaction history grow larger than the database.")
Acked-by: Han Zhou <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Jan 18, 2023
1 parent b02356e commit 7402dae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ovsdb/ovsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,5 +715,8 @@ ovsdb_replace(struct ovsdb *dst, struct ovsdb *src)

dst->rbac_role = ovsdb_get_table(dst, "RBAC_Role");

/* Get statistics from the new database. */
dst->n_atoms = src->n_atoms;

ovsdb_destroy(src);
}
18 changes: 18 additions & 0 deletions tests/ovsdb-server.at
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,24 @@ dnl After removing all the bridges, the number of atoms in the database
dnl should return to its initial value.
AT_CHECK([test $(get_memory_value atoms) -eq $initial_db_atoms])

dnl Add a few more resources.
for i in $(seq 1 10); do
cmd=$(add_ports $i $(($i / 4 + 1)))
AT_CHECK([ovs-vsctl --no-wait add-br br$i $cmd])
done
check_atoms

db_atoms_before_conversion=$(get_memory_value atoms)

dnl Trigger online conversion.
AT_CHECK([ovsdb-client convert $abs_top_srcdir/vswitchd/vswitch.ovsschema],
[0], [ignore], [ignore])

dnl Check that conversion didn't change the number of atoms and the history
dnl still has a reasonable size.
check_atoms
AT_CHECK([test $(get_memory_value atoms) -eq $db_atoms_before_conversion])

OVS_APP_EXIT_AND_WAIT([ovsdb-server])
AT_CLEANUP

Expand Down

0 comments on commit 7402dae

Please sign in to comment.