diff options
author | Ilya Maximets <i.maximets@ovn.org> | 2021-09-28 13:17:21 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2021-11-05 22:33:03 +0100 |
commit | 317b1bfd7dd315e241c158e6d4095002ff391ee3 (patch) | |
tree | 6930434f6777c0f49ab3e9616bfa49c4c1787109 /ovsdb/ovsdb.h | |
parent | 1bdda7b6d53c92e877b457157676aff326414c53 (diff) | |
download | openvswitch-317b1bfd7dd315e241c158e6d4095002ff391ee3.tar.gz |
ovsdb: Don't let transaction history grow larger than the database.
If user frequently changes a lot of rows in a database, transaction
history could grow way larger than the database itself. This wastes
a lot of memory and also makes monitor_cond_since slower than
usual monotor_cond if the transaction id is old enough, because
re-construction of the changes from a history is slower than just
creation of initial database snapshot. This is also the case if
user deleted a lot of data, so transaction history still holds all of
it while the database itself doesn't.
In case of current lb-per-service model in ovn-kubernetes, each
load-balancer is added to every logical switch/router. Such a
transaction touches more than a half of a OVN_Northbound database.
And each of these transactions is added to the transaction history.
Since transaction history depth is 100, in worst case scenario,
it will hold 100 copies of a database increasing memory consumption
dramatically. In tests with 3000 LBs and 120 LSs, memory goes up
to 3 GB, while holding at 30 MB if transaction history disabled in
the code.
Fixing that by keeping count of the number of ovsdb_atom's in the
database and not allowing the total number of atoms in transaction
history to grow larger than this value. Counting atoms is fairly
cheap because we don't need to iterate over them, so it doesn't have
significant performance impact. It would be ideal to measure the
size of individual atoms, but that will hit the performance.
Counting cells instead of atoms is not sufficient, because OVN
users are adding hundreds or thousands of atoms to a single cell,
so they are largely different in size.
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Han Zhou <hzhou@ovn.org>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Diffstat (limited to 'ovsdb/ovsdb.h')
-rw-r--r-- | ovsdb/ovsdb.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/ovsdb/ovsdb.h b/ovsdb/ovsdb.h index 4a7bd0f0e..ec2d235ec 100644 --- a/ovsdb/ovsdb.h +++ b/ovsdb/ovsdb.h @@ -90,8 +90,11 @@ struct ovsdb { /* History trasanctions for incremental monitor transfer. */ bool need_txn_history; /* Need to maintain history of transactions. */ unsigned int n_txn_history; /* Current number of history transactions. */ + unsigned int n_txn_history_atoms; /* Total number of atoms in history. */ struct ovs_list txn_history; /* Contains "struct ovsdb_txn_history_node. */ + size_t n_atoms; /* Total number of ovsdb atoms in the database. */ + /* Relay mode. */ bool is_relay; /* True, if database is in relay mode. */ /* List that holds transactions waiting to be forwarded to the server. */ |