7f7b2c
From 63807420f208364d5143dfc9246f9777e6ae934f Mon Sep 17 00:00:00 2001
7f7b2c
From: Ilya Maximets <i.maximets@ovn.org>
7f7b2c
Date: Fri, 11 Dec 2020 11:59:17 +0100
7f7b2c
Subject: [PATCH 4/7] nbctl: Remove column verification for partial updates.
7f7b2c
7f7b2c
Since this is not a read-modify-write sequence, it's not strictly
7f7b2c
necessary to verify that current value is exactly same while performing
7f7b2c
mutations.  Verification removal will allow to significantly reduce
7f7b2c
size of ovsdb transaction, because it will no longer contain all the
7f7b2c
data from the mutated column.
7f7b2c
7f7b2c
Before this change, addition of 1 new switch port to a logical switch
7f7b2c
with 1000 ports looked like this:
7f7b2c
7f7b2c
  {transact,
7f7b2c
      where: _uuid  == 'logical switch row uuid'
7f7b2c
      op   : wait
7f7b2c
      until: ==
7f7b2c
      rows : ports ['< list of current 1000 ports >']
7f7b2c
7f7b2c
      < create new lsp in Logical_Switch_Port table >
7f7b2c
7f7b2c
      where: _uuid  == 'logical switch row uuid'
7f7b2c
      op   :  mutate
7f7b2c
      mutations : ports insert ['< 1 uuid of a new lsp >']
7f7b2c
  }
7f7b2c
7f7b2c
After:
7f7b2c
7f7b2c
  {transact,
7f7b2c
      < create new lsp in Logical_Switch_Port table >
7f7b2c
7f7b2c
      where: _uuid  == 'logical switch row uuid'
7f7b2c
      op   :  mutate
7f7b2c
      mutations : ports insert ['< 1 uuid of a new lsp >']
7f7b2c
  }
7f7b2c
7f7b2c
This should relieve some pressure from the ovsdb-server since it will
7f7b2c
not need to parse and execute this huge 'wait' operation.
7f7b2c
7f7b2c
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
7f7b2c
Signed-off-by: Numan Siddique <numans@ovn.org>
7f7b2c
---
7f7b2c
 utilities/ovn-nbctl.c | 33 ---------------------------------
7f7b2c
 1 file changed, 33 deletions(-)
7f7b2c
7f7b2c
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
7f7b2c
index 7c4dce12a..835161f25 100644
7f7b2c
--- a/utilities/ovn-nbctl.c
7f7b2c
+++ b/utilities/ovn-nbctl.c
7f7b2c
@@ -1511,7 +1511,6 @@ nbctl_lsp_add(struct ctl_context *ctx)
7f7b2c
     }
7f7b2c
 
7f7b2c
     /* Insert the logical port into the logical switch. */
7f7b2c
-    nbrec_logical_switch_verify_ports(ls);
7f7b2c
     nbrec_logical_switch_update_ports_addvalue(ls, lsp);
7f7b2c
 
7f7b2c
     /* Updating runtime cache. */
7f7b2c
@@ -1532,7 +1531,6 @@ remove_lsp(struct ctl_context *ctx,
7f7b2c
     /* First remove 'lsp' from the array of ports.  This is what will
7f7b2c
      * actually cause the logical port to be deleted when the transaction is
7f7b2c
      * sent to the database server (due to garbage collection). */
7f7b2c
-    nbrec_logical_switch_verify_ports(ls);
7f7b2c
     nbrec_logical_switch_update_ports_delvalue(ls, lsp);
7f7b2c
 
7f7b2c
     /* Delete 'lsp' from the IDL.  This won't have a real effect on the
7f7b2c
@@ -2356,10 +2354,8 @@ nbctl_acl_add(struct ctl_context *ctx)
7f7b2c
 
7f7b2c
     /* Insert the acl into the logical switch/port group. */
7f7b2c
     if (pg) {
7f7b2c
-        nbrec_port_group_verify_acls(pg);
7f7b2c
         nbrec_port_group_update_acls_addvalue(pg, acl);
7f7b2c
     } else {
7f7b2c
-        nbrec_logical_switch_verify_acls(ls);
7f7b2c
         nbrec_logical_switch_update_acls_addvalue(ls, acl);
7f7b2c
     }
7f7b2c
 }
7f7b2c
@@ -2401,12 +2397,6 @@ nbctl_acl_del(struct ctl_context *ctx)
7f7b2c
     /* If priority and match are not specified, delete all ACLs with the
7f7b2c
      * specified direction. */
7f7b2c
     if (ctx->argc == 3) {
7f7b2c
-        if (pg) {
7f7b2c
-            nbrec_port_group_verify_acls(pg);
7f7b2c
-        } else {
7f7b2c
-            nbrec_logical_switch_verify_acls(ls);
7f7b2c
-        }
7f7b2c
-
7f7b2c
         for (size_t i = 0; i < n_acls; i++) {
7f7b2c
             if (!strcmp(direction, acls[i]->direction)) {
7f7b2c
                 if (pg) {
7f7b2c
@@ -2438,10 +2428,8 @@ nbctl_acl_del(struct ctl_context *ctx)
7f7b2c
         if (priority == acl->priority && !strcmp(ctx->argv[4], acl->match) &&
7f7b2c
              !strcmp(direction, acl->direction)) {
7f7b2c
             if (pg) {
7f7b2c
-                nbrec_port_group_verify_acls(pg);
7f7b2c
                 nbrec_port_group_update_acls_delvalue(pg, acl);
7f7b2c
             } else {
7f7b2c
-                nbrec_logical_switch_verify_acls(ls);
7f7b2c
                 nbrec_logical_switch_update_acls_delvalue(ls, acl);
7f7b2c
             }
7f7b2c
             return;
7f7b2c
@@ -2596,7 +2584,6 @@ nbctl_qos_add(struct ctl_context *ctx)
7f7b2c
     }
7f7b2c
 
7f7b2c
     /* Insert the qos rule the logical switch. */
7f7b2c
-    nbrec_logical_switch_verify_qos_rules(ls);
7f7b2c
     nbrec_logical_switch_update_qos_rules_addvalue(ls, qos);
7f7b2c
 }
7f7b2c
 
7f7b2c
@@ -2636,7 +2623,6 @@ nbctl_qos_del(struct ctl_context *ctx)
7f7b2c
     if (ctx->argc == 3) {
7f7b2c
         size_t i;
7f7b2c
 
7f7b2c
-        nbrec_logical_switch_verify_qos_rules(ls);
7f7b2c
         if (qos_rule_uuid) {
7f7b2c
             for (i = 0; i < ls->n_qos_rules; i++) {
7f7b2c
                 if (uuid_equals(qos_rule_uuid,
7f7b2c
@@ -2686,7 +2672,6 @@ nbctl_qos_del(struct ctl_context *ctx)
7f7b2c
 
7f7b2c
         if (priority == qos->priority && !strcmp(ctx->argv[4], qos->match) &&
7f7b2c
              !strcmp(direction, qos->direction)) {
7f7b2c
-            nbrec_logical_switch_verify_qos_rules(ls);
7f7b2c
             nbrec_logical_switch_update_qos_rules_delvalue(ls, qos);
7f7b2c
             return;
7f7b2c
         }
7f7b2c
@@ -3149,7 +3134,6 @@ nbctl_lr_lb_add(struct ctl_context *ctx)
7f7b2c
     }
7f7b2c
 
7f7b2c
     /* Insert the load balancer into the logical router. */
7f7b2c
-    nbrec_logical_router_verify_load_balancer(lr);
7f7b2c
     nbrec_logical_router_update_load_balancer_addvalue(lr, new_lb);
7f7b2c
 }
7f7b2c
 
7f7b2c
@@ -3183,7 +3167,6 @@ nbctl_lr_lb_del(struct ctl_context *ctx)
7f7b2c
 
7f7b2c
         if (uuid_equals(&del_lb->header_.uuid, &lb->header_.uuid)) {
7f7b2c
             /* Remove the matching rule. */
7f7b2c
-            nbrec_logical_router_verify_load_balancer(lr);
7f7b2c
             nbrec_logical_router_update_load_balancer_delvalue(lr, lb);
7f7b2c
             return;
7f7b2c
         }
7f7b2c
@@ -3258,7 +3241,6 @@ nbctl_ls_lb_add(struct ctl_context *ctx)
7f7b2c
     }
7f7b2c
 
7f7b2c
     /* Insert the load balancer into the logical switch. */
7f7b2c
-    nbrec_logical_switch_verify_load_balancer(ls);
7f7b2c
     nbrec_logical_switch_update_load_balancer_addvalue(ls, new_lb);
7f7b2c
 }
7f7b2c
 
7f7b2c
@@ -3292,7 +3274,6 @@ nbctl_ls_lb_del(struct ctl_context *ctx)
7f7b2c
 
7f7b2c
         if (uuid_equals(&del_lb->header_.uuid, &lb->header_.uuid)) {
7f7b2c
             /* Remove the matching rule. */
7f7b2c
-            nbrec_logical_switch_verify_load_balancer(ls);
7f7b2c
             nbrec_logical_switch_update_load_balancer_delvalue(ls, lb);
7f7b2c
             return;
7f7b2c
         }
7f7b2c
@@ -3721,7 +3702,6 @@ nbctl_lr_policy_add(struct ctl_context *ctx)
7f7b2c
     nbrec_logical_router_policy_set_options(policy, &options);
7f7b2c
     smap_destroy(&options);
7f7b2c
 
7f7b2c
-    nbrec_logical_router_verify_policies(lr);
7f7b2c
     nbrec_logical_router_update_policies_addvalue(lr, policy);
7f7b2c
     if (next_hop != NULL) {
7f7b2c
         free(next_hop);
7f7b2c
@@ -3761,7 +3741,6 @@ nbctl_lr_policy_del(struct ctl_context *ctx)
7f7b2c
     if (ctx->argc == 3) {
7f7b2c
         size_t i;
7f7b2c
 
7f7b2c
-        nbrec_logical_router_verify_policies(lr);
7f7b2c
         if (lr_policy_uuid) {
7f7b2c
             for (i = 0; i < lr->n_policies; i++) {
7f7b2c
                 if (uuid_equals(lr_policy_uuid,
7f7b2c
@@ -3796,7 +3775,6 @@ nbctl_lr_policy_del(struct ctl_context *ctx)
7f7b2c
         struct nbrec_logical_router_policy *routing_policy = lr->policies[i];
7f7b2c
         if (priority == routing_policy->priority &&
7f7b2c
             !strcmp(ctx->argv[3], routing_policy->match)) {
7f7b2c
-            nbrec_logical_router_verify_policies(lr);
7f7b2c
             nbrec_logical_router_update_policies_delvalue(lr, routing_policy);
7f7b2c
             return;
7f7b2c
         }
7f7b2c
@@ -3996,7 +3974,6 @@ nbctl_lr_route_add(struct ctl_context *ctx)
7f7b2c
         nbrec_logical_router_static_route_set_options(route, &options);
7f7b2c
     }
7f7b2c
 
7f7b2c
-    nbrec_logical_router_verify_static_routes(lr);
7f7b2c
     nbrec_logical_router_update_static_routes_addvalue(lr, route);
7f7b2c
 
7f7b2c
 cleanup:
7f7b2c
@@ -4055,7 +4032,6 @@ nbctl_lr_route_del(struct ctl_context *ctx)
7f7b2c
     }
7f7b2c
 
7f7b2c
     size_t n_removed = 0;
7f7b2c
-    nbrec_logical_router_verify_static_routes(lr);
7f7b2c
     for (size_t i = 0; i < lr->n_static_routes; i++) {
7f7b2c
         /* Compare route policy, if specified. */
7f7b2c
         if (policy) {
7f7b2c
@@ -4393,7 +4369,6 @@ nbctl_lr_nat_add(struct ctl_context *ctx)
7f7b2c
     smap_destroy(&nat_options);
7f7b2c
 
7f7b2c
     /* Insert the NAT into the logical router. */
7f7b2c
-    nbrec_logical_router_verify_nat(lr);
7f7b2c
     nbrec_logical_router_update_nat_addvalue(lr, nat);
7f7b2c
 
7f7b2c
 cleanup:
7f7b2c
@@ -4430,7 +4405,6 @@ nbctl_lr_nat_del(struct ctl_context *ctx)
7f7b2c
 
7f7b2c
     if (ctx->argc == 3) {
7f7b2c
         /*Deletes all NATs with the specified type. */
7f7b2c
-        nbrec_logical_router_verify_nat(lr);
7f7b2c
         for (size_t i = 0; i < lr->n_nat; i++) {
7f7b2c
             if (!strcmp(nat_type, lr->nat[i]->type)) {
7f7b2c
                 nbrec_logical_router_update_nat_delvalue(lr, lr->nat[i]);
7f7b2c
@@ -4457,7 +4431,6 @@ nbctl_lr_nat_del(struct ctl_context *ctx)
7f7b2c
             continue;
7f7b2c
         }
7f7b2c
         if (!strcmp(nat_type, nat->type) && !strcmp(nat_ip, old_ip)) {
7f7b2c
-            nbrec_logical_router_verify_nat(lr);
7f7b2c
             nbrec_logical_router_update_nat_delvalue(lr, nat);
7f7b2c
             should_return = true;
7f7b2c
         }
7f7b2c
@@ -4736,7 +4709,6 @@ nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx)
7f7b2c
     nbrec_gateway_chassis_set_priority(gc, priority);
7f7b2c
 
7f7b2c
     /* Insert the logical gateway chassis into the logical router port. */
7f7b2c
-    nbrec_logical_router_port_verify_gateway_chassis(lrp);
7f7b2c
     nbrec_logical_router_port_update_gateway_chassis_addvalue(lrp, gc);
7f7b2c
     free(gc_name);
7f7b2c
 }
7f7b2c
@@ -4754,7 +4726,6 @@ remove_gc(const struct nbrec_logical_router_port *lrp, size_t idx)
7f7b2c
          * will actually cause the gateway chassis to be deleted when the
7f7b2c
          * transaction is sent to the database server (due to garbage
7f7b2c
          * collection). */
7f7b2c
-        nbrec_logical_router_port_verify_gateway_chassis(lrp);
7f7b2c
         nbrec_logical_router_port_update_gateway_chassis_delvalue(lrp, gc);
7f7b2c
     }
7f7b2c
 
7f7b2c
@@ -4987,7 +4958,6 @@ nbctl_lrp_add(struct ctl_context *ctx)
7f7b2c
     }
7f7b2c
 
7f7b2c
     /* Insert the logical port into the logical router. */
7f7b2c
-    nbrec_logical_router_verify_ports(lr);
7f7b2c
     nbrec_logical_router_update_ports_addvalue(lr, lrp);
7f7b2c
 
7f7b2c
     /* Updating runtime cache. */
7f7b2c
@@ -5008,7 +4978,6 @@ remove_lrp(struct ctl_context *ctx,
7f7b2c
     /* First remove 'lrp' from the array of ports.  This is what will
7f7b2c
      * actually cause the logical port to be deleted when the transaction is
7f7b2c
      * sent to the database server (due to garbage collection). */
7f7b2c
-    nbrec_logical_router_verify_ports(lr);
7f7b2c
     nbrec_logical_router_update_ports_delvalue(lr, lrp);
7f7b2c
 
7f7b2c
     /* Delete 'lrp' from the IDL.  This won't have a real effect on
7f7b2c
@@ -5933,7 +5902,6 @@ cmd_ha_ch_grp_add_chassis(struct ctl_context *ctx)
7f7b2c
     nbrec_ha_chassis_set_chassis_name(ha_chassis, chassis_name);
7f7b2c
     nbrec_ha_chassis_set_priority(ha_chassis, priority);
7f7b2c
 
7f7b2c
-    nbrec_ha_chassis_group_verify_ha_chassis(ha_ch_grp);
7f7b2c
     nbrec_ha_chassis_group_update_ha_chassis_addvalue(ha_ch_grp, ha_chassis);
7f7b2c
 }
7f7b2c
 
7f7b2c
@@ -5962,7 +5930,6 @@ cmd_ha_ch_grp_remove_chassis(struct ctl_context *ctx)
7f7b2c
         return;
7f7b2c
     }
7f7b2c
 
7f7b2c
-    nbrec_ha_chassis_group_verify_ha_chassis(ha_ch_grp);
7f7b2c
     nbrec_ha_chassis_group_update_ha_chassis_delvalue(ha_ch_grp, ha_chassis);
7f7b2c
     nbrec_ha_chassis_delete(ha_chassis);
7f7b2c
 }
7f7b2c
-- 
7f7b2c
2.28.0
7f7b2c