1 /* Copyright (c) 2009, 2010 Nicira Networks.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
18 #include "ovsdb-idl.h"
27 #include "dynamic-string.h"
30 #include "ovsdb-data.h"
31 #include "ovsdb-error.h"
32 #include "ovsdb-idl-provider.h"
33 #include "poll-loop.h"
37 #define THIS_MODULE VLM_ovsdb_idl
40 /* An arc from one idl_row to another. When row A contains a UUID that
41 * references row B, this is represented by an arc from A (the source) to B
44 * Arcs from a row to itself are omitted, that is, src and dst are always
47 * Arcs are never duplicated, that is, even if there are multiple references
48 * from A to B, there is only a single arc from A to B.
50 * Arcs are directed: an arc from A to B is the converse of an an arc from B to
51 * A. Both an arc and its converse may both be present, if each row refers
52 * to the other circularly.
54 * The source and destination row may be in the same table or in different
57 struct ovsdb_idl_arc {
58 struct list src_node; /* In src->src_arcs list. */
59 struct list dst_node; /* In dst->dst_arcs list. */
60 struct ovsdb_idl_row *src; /* Source row. */
61 struct ovsdb_idl_row *dst; /* Destination row. */
65 const struct ovsdb_idl_class *class;
66 struct jsonrpc_session *session;
67 struct shash table_by_name;
68 struct ovsdb_idl_table *tables;
69 struct json *monitor_request_id;
70 unsigned int last_monitor_request_seqno;
71 unsigned int change_seqno;
73 /* Transaction support. */
74 struct ovsdb_idl_txn *txn;
75 struct hmap outstanding_txns;
78 struct ovsdb_idl_txn {
79 struct hmap_node hmap_node;
80 struct json *request_id;
81 struct ovsdb_idl *idl;
83 enum ovsdb_idl_txn_status status;
91 struct json *inc_where;
92 unsigned int inc_index;
93 int64_t inc_new_value;
96 struct hmap inserted_rows;
99 struct ovsdb_idl_txn_insert {
100 struct hmap_node hmap_node; /* In struct ovsdb_idl_txn's inserted_rows. */
101 struct uuid dummy; /* Dummy UUID used locally. */
102 int op_index; /* Index into transaction's operation array. */
103 struct uuid real; /* Real UUID used by database server. */
106 static struct vlog_rate_limit syntax_rl = VLOG_RATE_LIMIT_INIT(1, 5);
107 static struct vlog_rate_limit semantic_rl = VLOG_RATE_LIMIT_INIT(1, 5);
109 static void ovsdb_idl_clear(struct ovsdb_idl *);
110 static void ovsdb_idl_send_monitor_request(struct ovsdb_idl *);
111 static void ovsdb_idl_parse_update(struct ovsdb_idl *, const struct json *);
112 static struct ovsdb_error *ovsdb_idl_parse_update__(struct ovsdb_idl *,
113 const struct json *);
114 static void ovsdb_idl_process_update(struct ovsdb_idl_table *,
116 const struct json *old,
117 const struct json *new);
118 static void ovsdb_idl_insert_row(struct ovsdb_idl_row *, const struct json *);
119 static void ovsdb_idl_delete_row(struct ovsdb_idl_row *);
120 static void ovsdb_idl_modify_row(struct ovsdb_idl_row *, const struct json *);
122 static bool ovsdb_idl_row_is_orphan(const struct ovsdb_idl_row *);
123 static struct ovsdb_idl_row *ovsdb_idl_row_create__(
124 const struct ovsdb_idl_table_class *);
125 static struct ovsdb_idl_row *ovsdb_idl_row_create(struct ovsdb_idl_table *,
126 const struct uuid *);
127 static void ovsdb_idl_row_destroy(struct ovsdb_idl_row *);
129 static void ovsdb_idl_row_parse(struct ovsdb_idl_row *);
130 static void ovsdb_idl_row_unparse(struct ovsdb_idl_row *);
131 static void ovsdb_idl_row_clear_old(struct ovsdb_idl_row *);
132 static void ovsdb_idl_row_clear_new(struct ovsdb_idl_row *);
134 static void ovsdb_idl_txn_abort_all(struct ovsdb_idl *);
135 static bool ovsdb_idl_txn_process_reply(struct ovsdb_idl *,
136 const struct jsonrpc_msg *msg);
139 ovsdb_idl_create(const char *remote, const struct ovsdb_idl_class *class)
141 struct ovsdb_idl *idl;
144 idl = xzalloc(sizeof *idl);
146 idl->session = jsonrpc_session_open(remote);
147 shash_init(&idl->table_by_name);
148 idl->tables = xmalloc(class->n_tables * sizeof *idl->tables);
149 for (i = 0; i < class->n_tables; i++) {
150 const struct ovsdb_idl_table_class *tc = &class->tables[i];
151 struct ovsdb_idl_table *table = &idl->tables[i];
154 assert(!shash_find(&idl->table_by_name, tc->name));
155 shash_add(&idl->table_by_name, tc->name, table);
157 shash_init(&table->columns);
158 for (j = 0; j < tc->n_columns; j++) {
159 const struct ovsdb_idl_column *column = &tc->columns[j];
161 assert(!shash_find(&table->columns, column->name));
162 shash_add(&table->columns, column->name, column);
164 hmap_init(&table->rows);
167 idl->last_monitor_request_seqno = UINT_MAX;
168 hmap_init(&idl->outstanding_txns);
174 ovsdb_idl_destroy(struct ovsdb_idl *idl)
180 ovsdb_idl_clear(idl);
181 jsonrpc_session_close(idl->session);
183 for (i = 0; i < idl->class->n_tables; i++) {
184 struct ovsdb_idl_table *table = &idl->tables[i];
185 shash_destroy(&table->columns);
186 hmap_destroy(&table->rows);
188 shash_destroy(&idl->table_by_name);
190 json_destroy(idl->monitor_request_id);
196 ovsdb_idl_clear(struct ovsdb_idl *idl)
198 bool changed = false;
201 for (i = 0; i < idl->class->n_tables; i++) {
202 struct ovsdb_idl_table *table = &idl->tables[i];
203 struct ovsdb_idl_row *row, *next_row;
205 if (hmap_is_empty(&table->rows)) {
210 HMAP_FOR_EACH_SAFE (row, next_row, struct ovsdb_idl_row, hmap_node,
212 struct ovsdb_idl_arc *arc, *next_arc;
214 if (!ovsdb_idl_row_is_orphan(row)) {
215 ovsdb_idl_row_unparse(row);
217 LIST_FOR_EACH_SAFE (arc, next_arc, struct ovsdb_idl_arc, src_node,
221 /* No need to do anything with dst_arcs: some node has those arcs
222 * as forward arcs and will destroy them itself. */
224 ovsdb_idl_row_destroy(row);
234 ovsdb_idl_run(struct ovsdb_idl *idl)
239 jsonrpc_session_run(idl->session);
240 for (i = 0; jsonrpc_session_is_connected(idl->session) && i < 50; i++) {
241 struct jsonrpc_msg *msg, *reply;
244 seqno = jsonrpc_session_get_seqno(idl->session);
245 if (idl->last_monitor_request_seqno != seqno) {
246 idl->last_monitor_request_seqno = seqno;
247 ovsdb_idl_txn_abort_all(idl);
248 ovsdb_idl_send_monitor_request(idl);
252 msg = jsonrpc_session_recv(idl->session);
258 if (msg->type == JSONRPC_NOTIFY
259 && !strcmp(msg->method, "update")
260 && msg->params->type == JSON_ARRAY
261 && msg->params->u.array.n == 2
262 && msg->params->u.array.elems[0]->type == JSON_NULL) {
263 ovsdb_idl_parse_update(idl, msg->params->u.array.elems[1]);
264 } else if (msg->type == JSONRPC_REPLY
265 && idl->monitor_request_id
266 && json_equal(idl->monitor_request_id, msg->id)) {
267 json_destroy(idl->monitor_request_id);
268 idl->monitor_request_id = NULL;
269 ovsdb_idl_clear(idl);
270 ovsdb_idl_parse_update(idl, msg->result);
271 } else if (msg->type == JSONRPC_REPLY
272 && msg->id && msg->id->type == JSON_STRING
273 && !strcmp(msg->id->u.string, "echo")) {
274 /* It's a reply to our echo request. Ignore it. */
275 } else if ((msg->type == JSONRPC_ERROR
276 || msg->type == JSONRPC_REPLY)
277 && ovsdb_idl_txn_process_reply(idl, msg)) {
278 /* ovsdb_idl_txn_process_reply() did everything needful. */
280 /* This can happen if ovsdb_idl_txn_destroy() is called to destroy
281 * a transaction before we receive the reply, so keep the log level
283 VLOG_DBG("%s: received unexpected %s message",
284 jsonrpc_session_get_name(idl->session),
285 jsonrpc_msg_type_to_string(msg->type));
288 jsonrpc_session_send(idl->session, reply);
290 jsonrpc_msg_destroy(msg);
295 ovsdb_idl_wait(struct ovsdb_idl *idl)
297 jsonrpc_session_wait(idl->session);
298 jsonrpc_session_recv_wait(idl->session);
302 ovsdb_idl_get_seqno(const struct ovsdb_idl *idl)
304 return idl->change_seqno;
308 ovsdb_idl_has_ever_connected(const struct ovsdb_idl *idl)
310 return ovsdb_idl_get_seqno(idl) != 0;
314 ovsdb_idl_force_reconnect(struct ovsdb_idl *idl)
316 jsonrpc_session_force_reconnect(idl->session);
320 ovsdb_idl_send_monitor_request(struct ovsdb_idl *idl)
322 struct json *monitor_requests;
323 struct jsonrpc_msg *msg;
326 monitor_requests = json_object_create();
327 for (i = 0; i < idl->class->n_tables; i++) {
328 const struct ovsdb_idl_table *table = &idl->tables[i];
329 const struct ovsdb_idl_table_class *tc = table->class;
330 struct json *monitor_request, *columns;
333 monitor_request = json_object_create();
334 columns = json_array_create_empty();
335 for (i = 0; i < tc->n_columns; i++) {
336 const struct ovsdb_idl_column *column = &tc->columns[i];
337 json_array_add(columns, json_string_create(column->name));
339 json_object_put(monitor_request, "columns", columns);
340 json_object_put(monitor_requests, tc->name, monitor_request);
343 json_destroy(idl->monitor_request_id);
344 msg = jsonrpc_create_request(
345 "monitor", json_array_create_2(json_null_create(), monitor_requests),
346 &idl->monitor_request_id);
347 jsonrpc_session_send(idl->session, msg);
351 ovsdb_idl_parse_update(struct ovsdb_idl *idl, const struct json *table_updates)
353 struct ovsdb_error *error;
357 error = ovsdb_idl_parse_update__(idl, table_updates);
359 if (!VLOG_DROP_WARN(&syntax_rl)) {
360 char *s = ovsdb_error_to_string(error);
361 VLOG_WARN_RL(&syntax_rl, "%s", s);
364 ovsdb_error_destroy(error);
368 static struct ovsdb_error *
369 ovsdb_idl_parse_update__(struct ovsdb_idl *idl,
370 const struct json *table_updates)
372 const struct shash_node *tables_node;
374 if (table_updates->type != JSON_OBJECT) {
375 return ovsdb_syntax_error(table_updates, NULL,
376 "<table-updates> is not an object");
378 SHASH_FOR_EACH (tables_node, json_object(table_updates)) {
379 const struct json *table_update = tables_node->data;
380 const struct shash_node *table_node;
381 struct ovsdb_idl_table *table;
383 table = shash_find_data(&idl->table_by_name, tables_node->name);
385 return ovsdb_syntax_error(
387 "<table-updates> includes unknown table \"%s\"",
391 if (table_update->type != JSON_OBJECT) {
392 return ovsdb_syntax_error(table_update, NULL,
393 "<table-update> for table \"%s\" is "
394 "not an object", table->class->name);
396 SHASH_FOR_EACH (table_node, json_object(table_update)) {
397 const struct json *row_update = table_node->data;
398 const struct json *old_json, *new_json;
401 if (!uuid_from_string(&uuid, table_node->name)) {
402 return ovsdb_syntax_error(table_update, NULL,
403 "<table-update> for table \"%s\" "
405 "\"%s\" as member name",
409 if (row_update->type != JSON_OBJECT) {
410 return ovsdb_syntax_error(row_update, NULL,
411 "<table-update> for table \"%s\" "
412 "contains <row-update> for %s that "
418 old_json = shash_find_data(json_object(row_update), "old");
419 new_json = shash_find_data(json_object(row_update), "new");
420 if (old_json && old_json->type != JSON_OBJECT) {
421 return ovsdb_syntax_error(old_json, NULL,
422 "\"old\" <row> is not object");
423 } else if (new_json && new_json->type != JSON_OBJECT) {
424 return ovsdb_syntax_error(new_json, NULL,
425 "\"new\" <row> is not object");
426 } else if ((old_json != NULL) + (new_json != NULL)
427 != shash_count(json_object(row_update))) {
428 return ovsdb_syntax_error(row_update, NULL,
429 "<row-update> contains unexpected "
431 } else if (!old_json && !new_json) {
432 return ovsdb_syntax_error(row_update, NULL,
433 "<row-update> missing \"old\" "
434 "and \"new\" members");
437 ovsdb_idl_process_update(table, &uuid, old_json, new_json);
444 static struct ovsdb_idl_row *
445 ovsdb_idl_get_row(struct ovsdb_idl_table *table, const struct uuid *uuid)
447 struct ovsdb_idl_row *row;
449 HMAP_FOR_EACH_WITH_HASH (row, struct ovsdb_idl_row, hmap_node,
450 uuid_hash(uuid), &table->rows) {
451 if (uuid_equals(&row->uuid, uuid)) {
459 ovsdb_idl_process_update(struct ovsdb_idl_table *table,
460 const struct uuid *uuid, const struct json *old,
461 const struct json *new)
463 struct ovsdb_idl_row *row;
465 row = ovsdb_idl_get_row(table, uuid);
468 if (row && !ovsdb_idl_row_is_orphan(row)) {
469 /* XXX perhaps we should check the 'old' values? */
470 ovsdb_idl_delete_row(row);
472 VLOG_WARN_RL(&semantic_rl, "cannot delete missing row "UUID_FMT" "
474 UUID_ARGS(uuid), table->class->name);
479 ovsdb_idl_insert_row(ovsdb_idl_row_create(table, uuid), new);
480 } else if (ovsdb_idl_row_is_orphan(row)) {
481 ovsdb_idl_insert_row(row, new);
483 VLOG_WARN_RL(&semantic_rl, "cannot add existing row "UUID_FMT" to "
484 "table %s", UUID_ARGS(uuid), table->class->name);
485 ovsdb_idl_modify_row(row, new);
490 /* XXX perhaps we should check the 'old' values? */
491 if (!ovsdb_idl_row_is_orphan(row)) {
492 ovsdb_idl_modify_row(row, new);
494 VLOG_WARN_RL(&semantic_rl, "cannot modify missing but "
495 "referenced row "UUID_FMT" in table %s",
496 UUID_ARGS(uuid), table->class->name);
497 ovsdb_idl_insert_row(row, new);
500 VLOG_WARN_RL(&semantic_rl, "cannot modify missing row "UUID_FMT" "
501 "in table %s", UUID_ARGS(uuid), table->class->name);
502 ovsdb_idl_insert_row(ovsdb_idl_row_create(table, uuid), new);
508 ovsdb_idl_row_update(struct ovsdb_idl_row *row, const struct json *row_json)
510 struct ovsdb_idl_table *table = row->table;
511 struct shash_node *node;
513 SHASH_FOR_EACH (node, json_object(row_json)) {
514 const char *column_name = node->name;
515 const struct ovsdb_idl_column *column;
516 struct ovsdb_datum datum;
517 struct ovsdb_error *error;
519 column = shash_find_data(&table->columns, column_name);
521 VLOG_WARN_RL(&syntax_rl, "unknown column %s updating row "UUID_FMT,
522 column_name, UUID_ARGS(&row->uuid));
526 error = ovsdb_datum_from_json(&datum, &column->type, node->data, NULL);
528 ovsdb_datum_swap(&row->old[column - table->class->columns],
530 ovsdb_datum_destroy(&datum, &column->type);
532 char *s = ovsdb_error_to_string(error);
533 VLOG_WARN_RL(&syntax_rl, "error parsing column %s in row "UUID_FMT
534 " in table %s: %s", column_name,
535 UUID_ARGS(&row->uuid), table->class->name, s);
537 ovsdb_error_destroy(error);
543 ovsdb_idl_row_is_orphan(const struct ovsdb_idl_row *row)
549 ovsdb_idl_row_parse(struct ovsdb_idl_row *row)
551 const struct ovsdb_idl_table_class *class = row->table->class;
554 for (i = 0; i < class->n_columns; i++) {
555 const struct ovsdb_idl_column *c = &class->columns[i];
556 (c->parse)(row, &row->old[i]);
561 ovsdb_idl_row_unparse(struct ovsdb_idl_row *row)
563 const struct ovsdb_idl_table_class *class = row->table->class;
566 for (i = 0; i < class->n_columns; i++) {
567 const struct ovsdb_idl_column *c = &class->columns[i];
573 ovsdb_idl_row_clear_old(struct ovsdb_idl_row *row)
575 assert(row->old == row->new);
576 if (!ovsdb_idl_row_is_orphan(row)) {
577 const struct ovsdb_idl_table_class *class = row->table->class;
580 for (i = 0; i < class->n_columns; i++) {
581 ovsdb_datum_destroy(&row->old[i], &class->columns[i].type);
584 row->old = row->new = NULL;
589 ovsdb_idl_row_clear_new(struct ovsdb_idl_row *row)
591 if (row->old != row->new) {
593 const struct ovsdb_idl_table_class *class = row->table->class;
596 BITMAP_FOR_EACH_1 (i, class->n_columns, row->written) {
597 ovsdb_datum_destroy(&row->new[i], &class->columns[i].type);
608 ovsdb_idl_row_clear_arcs(struct ovsdb_idl_row *row, bool destroy_dsts)
610 struct ovsdb_idl_arc *arc, *next;
612 /* Delete all forward arcs. If 'destroy_dsts', destroy any orphaned rows
613 * that this causes to be unreferenced. */
614 LIST_FOR_EACH_SAFE (arc, next, struct ovsdb_idl_arc, src_node,
616 list_remove(&arc->dst_node);
618 && ovsdb_idl_row_is_orphan(arc->dst)
619 && list_is_empty(&arc->dst->dst_arcs)) {
620 ovsdb_idl_row_destroy(arc->dst);
624 list_init(&row->src_arcs);
627 /* Force nodes that reference 'row' to reparse. */
629 ovsdb_idl_row_reparse_backrefs(struct ovsdb_idl_row *row)
631 struct ovsdb_idl_arc *arc, *next;
633 /* This is trickier than it looks. ovsdb_idl_row_clear_arcs() will destroy
634 * 'arc', so we need to use the "safe" variant of list traversal. However,
635 * calling an ovsdb_idl_column's 'parse' function will add an arc
636 * equivalent to 'arc' to row->arcs. That could be a problem for
637 * traversal, but it adds it at the beginning of the list to prevent us
638 * from stumbling upon it again.
640 * (If duplicate arcs were possible then we would need to make sure that
641 * 'next' didn't also point into 'arc''s destination, but we forbid
642 * duplicate arcs.) */
643 LIST_FOR_EACH_SAFE (arc, next, struct ovsdb_idl_arc, dst_node,
645 struct ovsdb_idl_row *ref = arc->src;
647 ovsdb_idl_row_unparse(ref);
648 ovsdb_idl_row_clear_arcs(ref, false);
649 ovsdb_idl_row_parse(ref);
653 static struct ovsdb_idl_row *
654 ovsdb_idl_row_create__(const struct ovsdb_idl_table_class *class)
656 struct ovsdb_idl_row *row = xzalloc(class->allocation_size);
657 list_init(&row->src_arcs);
658 list_init(&row->dst_arcs);
659 hmap_node_nullify(&row->txn_node);
663 static struct ovsdb_idl_row *
664 ovsdb_idl_row_create(struct ovsdb_idl_table *table, const struct uuid *uuid)
666 struct ovsdb_idl_row *row = ovsdb_idl_row_create__(table->class);
667 hmap_insert(&table->rows, &row->hmap_node, uuid_hash(uuid));
674 ovsdb_idl_row_destroy(struct ovsdb_idl_row *row)
677 ovsdb_idl_row_clear_old(row);
678 hmap_remove(&row->table->rows, &row->hmap_node);
684 ovsdb_idl_insert_row(struct ovsdb_idl_row *row, const struct json *row_json)
686 const struct ovsdb_idl_table_class *class = row->table->class;
689 assert(!row->old && !row->new);
690 row->old = row->new = xmalloc(class->n_columns * sizeof *row->old);
691 for (i = 0; i < class->n_columns; i++) {
692 ovsdb_datum_init_default(&row->old[i], &class->columns[i].type);
694 ovsdb_idl_row_update(row, row_json);
695 ovsdb_idl_row_parse(row);
697 ovsdb_idl_row_reparse_backrefs(row);
701 ovsdb_idl_delete_row(struct ovsdb_idl_row *row)
703 ovsdb_idl_row_unparse(row);
704 ovsdb_idl_row_clear_arcs(row, true);
705 ovsdb_idl_row_clear_old(row);
706 if (list_is_empty(&row->dst_arcs)) {
707 ovsdb_idl_row_destroy(row);
709 ovsdb_idl_row_reparse_backrefs(row);
714 ovsdb_idl_modify_row(struct ovsdb_idl_row *row, const struct json *row_json)
716 ovsdb_idl_row_unparse(row);
717 ovsdb_idl_row_clear_arcs(row, true);
718 ovsdb_idl_row_update(row, row_json);
719 ovsdb_idl_row_parse(row);
723 may_add_arc(const struct ovsdb_idl_row *src, const struct ovsdb_idl_row *dst)
725 const struct ovsdb_idl_arc *arc;
732 /* No duplicate arcs.
734 * We only need to test whether the first arc in dst->dst_arcs originates
735 * at 'src', since we add all of the arcs from a given source in a clump
736 * (in a single call to ovsdb_idl_row_parse()) and new arcs are always
737 * added at the front of the dst_arcs list. */
738 if (list_is_empty(&dst->dst_arcs)) {
741 arc = CONTAINER_OF(dst->dst_arcs.next, struct ovsdb_idl_arc, dst_node);
742 return arc->src != src;
745 static struct ovsdb_idl_table *
746 ovsdb_idl_table_from_class(const struct ovsdb_idl *idl,
747 const struct ovsdb_idl_table_class *table_class)
749 return &idl->tables[table_class - idl->class->tables];
752 struct ovsdb_idl_row *
753 ovsdb_idl_get_row_arc(struct ovsdb_idl_row *src,
754 struct ovsdb_idl_table_class *dst_table_class,
755 const struct uuid *dst_uuid)
757 struct ovsdb_idl *idl = src->table->idl;
758 struct ovsdb_idl_table *dst_table;
759 struct ovsdb_idl_arc *arc;
760 struct ovsdb_idl_row *dst;
762 dst_table = ovsdb_idl_table_from_class(idl, dst_table_class);
763 dst = ovsdb_idl_get_row(dst_table, dst_uuid);
765 /* We're being called from ovsdb_idl_txn_write(). We must not update
766 * any arcs, because the transaction will be backed out at commit or
767 * abort time and we don't want our graph screwed up.
769 * Just return the destination row, if there is one and it has not been
771 if (dst && (hmap_node_is_null(&dst->txn_node) || dst->new)) {
776 /* We're being called from some other context. Update the graph. */
778 dst = ovsdb_idl_row_create(dst_table, dst_uuid);
781 /* Add a new arc, if it wouldn't be a self-arc or a duplicate arc. */
782 if (may_add_arc(src, dst)) {
783 /* The arc *must* be added at the front of the dst_arcs list. See
784 * ovsdb_idl_row_reparse_backrefs() for details. */
785 arc = xmalloc(sizeof *arc);
786 list_push_front(&src->src_arcs, &arc->src_node);
787 list_push_front(&dst->dst_arcs, &arc->dst_node);
792 return !ovsdb_idl_row_is_orphan(dst) ? dst : NULL;
796 const struct ovsdb_idl_row *
797 ovsdb_idl_get_row_for_uuid(const struct ovsdb_idl *idl,
798 const struct ovsdb_idl_table_class *tc,
799 const struct uuid *uuid)
801 return ovsdb_idl_get_row(ovsdb_idl_table_from_class(idl, tc), uuid);
804 static struct ovsdb_idl_row *
805 next_real_row(struct ovsdb_idl_table *table, struct hmap_node *node)
807 for (; node; node = hmap_next(&table->rows, node)) {
808 struct ovsdb_idl_row *row;
810 row = CONTAINER_OF(node, struct ovsdb_idl_row, hmap_node);
811 if (row->new || !ovsdb_idl_row_is_orphan(row)) {
818 const struct ovsdb_idl_row *
819 ovsdb_idl_first_row(const struct ovsdb_idl *idl,
820 const struct ovsdb_idl_table_class *table_class)
822 struct ovsdb_idl_table *table
823 = ovsdb_idl_table_from_class(idl, table_class);
824 return next_real_row(table, hmap_first(&table->rows));
827 const struct ovsdb_idl_row *
828 ovsdb_idl_next_row(const struct ovsdb_idl_row *row)
830 struct ovsdb_idl_table *table = row->table;
832 return next_real_row(table, hmap_next(&table->rows, &row->hmap_node));
837 static void ovsdb_idl_txn_complete(struct ovsdb_idl_txn *txn,
838 enum ovsdb_idl_txn_status);
841 ovsdb_idl_txn_status_to_string(enum ovsdb_idl_txn_status status)
860 struct ovsdb_idl_txn *
861 ovsdb_idl_txn_create(struct ovsdb_idl *idl)
863 struct ovsdb_idl_txn *txn;
866 idl->txn = txn = xmalloc(sizeof *txn);
867 txn->request_id = NULL;
869 hmap_init(&txn->txn_rows);
870 txn->status = TXN_INCOMPLETE;
872 txn->dry_run = false;
873 ds_init(&txn->comment);
875 txn->inc_table = NULL;
876 txn->inc_column = NULL;
877 txn->inc_where = NULL;
879 hmap_init(&txn->inserted_rows);
885 ovsdb_idl_txn_add_comment(struct ovsdb_idl_txn *txn, const char *s)
887 if (txn->comment.length) {
888 ds_put_char(&txn->comment, '\n');
890 ds_put_cstr(&txn->comment, s);
894 ovsdb_idl_txn_set_dry_run(struct ovsdb_idl_txn *txn)
900 ovsdb_idl_txn_increment(struct ovsdb_idl_txn *txn, const char *table,
901 const char *column, const struct json *where)
903 assert(!txn->inc_table);
904 txn->inc_table = xstrdup(table);
905 txn->inc_column = xstrdup(column);
906 txn->inc_where = where ? json_clone(where) : json_array_create_empty();
910 ovsdb_idl_txn_destroy(struct ovsdb_idl_txn *txn)
912 struct ovsdb_idl_txn_insert *insert, *next;
914 json_destroy(txn->request_id);
915 if (txn->status == TXN_INCOMPLETE) {
916 hmap_remove(&txn->idl->outstanding_txns, &txn->hmap_node);
918 ovsdb_idl_txn_abort(txn);
919 ds_destroy(&txn->comment);
921 free(txn->inc_table);
922 free(txn->inc_column);
923 json_destroy(txn->inc_where);
924 HMAP_FOR_EACH_SAFE (insert, next, struct ovsdb_idl_txn_insert, hmap_node,
925 &txn->inserted_rows) {
928 hmap_destroy(&txn->inserted_rows);
933 ovsdb_idl_txn_wait(const struct ovsdb_idl_txn *txn)
935 if (txn->status != TXN_INCOMPLETE) {
936 poll_immediate_wake();
941 where_uuid_equals(const struct uuid *uuid)
946 json_string_create("_uuid"),
947 json_string_create("=="),
949 json_string_create("uuid"),
950 json_string_create_nocopy(
951 xasprintf(UUID_FMT, UUID_ARGS(uuid))))));
955 uuid_name_from_uuid(const struct uuid *uuid)
960 name = xasprintf("row"UUID_FMT, UUID_ARGS(uuid));
961 for (p = name; *p != '\0'; p++) {
970 static const struct ovsdb_idl_row *
971 ovsdb_idl_txn_get_row(const struct ovsdb_idl_txn *txn, const struct uuid *uuid)
973 const struct ovsdb_idl_row *row;
975 HMAP_FOR_EACH_WITH_HASH (row, struct ovsdb_idl_row, txn_node,
976 uuid_hash(uuid), &txn->txn_rows) {
977 if (uuid_equals(&row->uuid, uuid)) {
984 /* XXX there must be a cleaner way to do this */
986 substitute_uuids(struct json *json, const struct ovsdb_idl_txn *txn)
988 if (json->type == JSON_ARRAY) {
992 if (json->u.array.n == 2
993 && json->u.array.elems[0]->type == JSON_STRING
994 && json->u.array.elems[1]->type == JSON_STRING
995 && !strcmp(json->u.array.elems[0]->u.string, "uuid")
996 && uuid_from_string(&uuid, json->u.array.elems[1]->u.string)) {
997 const struct ovsdb_idl_row *row;
999 row = ovsdb_idl_txn_get_row(txn, &uuid);
1000 if (row && !row->old && row->new) {
1003 return json_array_create_2(
1004 json_string_create("named-uuid"),
1005 json_string_create_nocopy(uuid_name_from_uuid(&uuid)));
1009 for (i = 0; i < json->u.array.n; i++) {
1010 json->u.array.elems[i] = substitute_uuids(json->u.array.elems[i],
1013 } else if (json->type == JSON_OBJECT) {
1014 struct shash_node *node;
1016 SHASH_FOR_EACH (node, json_object(json)) {
1017 node->data = substitute_uuids(node->data, txn);
1024 ovsdb_idl_txn_disassemble(struct ovsdb_idl_txn *txn)
1026 struct ovsdb_idl_row *row, *next;
1028 /* This must happen early. Otherwise, ovsdb_idl_row_parse() will call an
1029 * ovsdb_idl_column's 'parse' function, which will call
1030 * ovsdb_idl_get_row_arc(), which will seen that the IDL is in a
1031 * transaction and fail to update the graph. */
1032 txn->idl->txn = NULL;
1034 HMAP_FOR_EACH_SAFE (row, next, struct ovsdb_idl_row, txn_node,
1038 ovsdb_idl_row_unparse(row);
1039 ovsdb_idl_row_clear_arcs(row, false);
1040 ovsdb_idl_row_parse(row);
1043 ovsdb_idl_row_unparse(row);
1045 ovsdb_idl_row_clear_new(row);
1048 row->prereqs = NULL;
1051 row->written = NULL;
1053 hmap_remove(&txn->txn_rows, &row->txn_node);
1054 hmap_node_nullify(&row->txn_node);
1056 hmap_remove(&row->table->rows, &row->hmap_node);
1060 hmap_destroy(&txn->txn_rows);
1061 hmap_init(&txn->txn_rows);
1064 enum ovsdb_idl_txn_status
1065 ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn)
1067 struct ovsdb_idl_row *row;
1068 struct json *operations;
1071 if (txn != txn->idl->txn) {
1075 operations = json_array_create_empty();
1077 /* Add prerequisites and declarations of new rows. */
1078 HMAP_FOR_EACH (row, struct ovsdb_idl_row, txn_node, &txn->txn_rows) {
1079 /* XXX check that deleted rows exist even if no prereqs? */
1081 const struct ovsdb_idl_table_class *class = row->table->class;
1082 size_t n_columns = class->n_columns;
1083 struct json *op, *columns, *row_json;
1086 op = json_object_create();
1087 json_array_add(operations, op);
1088 json_object_put_string(op, "op", "wait");
1089 json_object_put_string(op, "table", class->name);
1090 json_object_put(op, "timeout", json_integer_create(0));
1091 json_object_put(op, "where", where_uuid_equals(&row->uuid));
1092 json_object_put_string(op, "until", "==");
1093 columns = json_array_create_empty();
1094 json_object_put(op, "columns", columns);
1095 row_json = json_object_create();
1096 json_object_put(op, "rows", json_array_create_1(row_json));
1098 BITMAP_FOR_EACH_1 (idx, n_columns, row->prereqs) {
1099 const struct ovsdb_idl_column *column = &class->columns[idx];
1100 json_array_add(columns, json_string_create(column->name));
1101 json_object_put(row_json, column->name,
1102 ovsdb_datum_to_json(&row->old[idx],
1109 any_updates = false;
1110 HMAP_FOR_EACH (row, struct ovsdb_idl_row, txn_node, &txn->txn_rows) {
1111 const struct ovsdb_idl_table_class *class = row->table->class;
1113 if (row->old == row->new) {
1115 } else if (!row->new) {
1116 struct json *op = json_object_create();
1117 json_object_put_string(op, "op", "delete");
1118 json_object_put_string(op, "table", class->name);
1119 json_object_put(op, "where", where_uuid_equals(&row->uuid));
1120 json_array_add(operations, op);
1123 struct json *row_json;
1127 op = json_object_create();
1128 json_object_put_string(op, "op", row->old ? "update" : "insert");
1129 json_object_put_string(op, "table", class->name);
1131 json_object_put(op, "where", where_uuid_equals(&row->uuid));
1133 struct ovsdb_idl_txn_insert *insert;
1135 json_object_put(op, "uuid-name",
1136 json_string_create_nocopy(
1137 uuid_name_from_uuid(&row->uuid)));
1139 insert = xmalloc(sizeof *insert);
1140 insert->dummy = row->uuid;
1141 insert->op_index = operations->u.array.n;
1142 uuid_zero(&insert->real);
1143 hmap_insert(&txn->inserted_rows, &insert->hmap_node,
1144 uuid_hash(&insert->dummy));
1146 row_json = json_object_create();
1147 json_object_put(op, "row", row_json);
1149 BITMAP_FOR_EACH_1 (idx, class->n_columns, row->written) {
1150 const struct ovsdb_idl_column *column = &class->columns[idx];
1153 ? !ovsdb_datum_equals(&row->old[idx], &row->new[idx],
1155 : !ovsdb_datum_is_default(&row->new[idx], &column->type)) {
1156 json_object_put(row_json, column->name,
1158 ovsdb_datum_to_json(&row->new[idx],
1164 if (!row->old || !shash_is_empty(json_object(row_json))) {
1165 json_array_add(operations, op);
1173 /* Add increment. */
1174 if (txn->inc_table && any_updates) {
1177 txn->inc_index = operations->u.array.n;
1179 op = json_object_create();
1180 json_object_put_string(op, "op", "mutate");
1181 json_object_put_string(op, "table", txn->inc_table);
1182 json_object_put(op, "where",
1183 substitute_uuids(json_clone(txn->inc_where), txn));
1184 json_object_put(op, "mutations",
1185 json_array_create_1(
1186 json_array_create_3(
1187 json_string_create(txn->inc_column),
1188 json_string_create("+="),
1189 json_integer_create(1))));
1190 json_array_add(operations, op);
1192 op = json_object_create();
1193 json_object_put_string(op, "op", "select");
1194 json_object_put_string(op, "table", txn->inc_table);
1195 json_object_put(op, "where",
1196 substitute_uuids(json_clone(txn->inc_where), txn));
1197 json_object_put(op, "columns",
1198 json_array_create_1(json_string_create(
1200 json_array_add(operations, op);
1203 if (txn->comment.length) {
1204 struct json *op = json_object_create();
1205 json_object_put_string(op, "op", "comment");
1206 json_object_put_string(op, "comment", ds_cstr(&txn->comment));
1207 json_array_add(operations, op);
1211 struct json *op = json_object_create();
1212 json_object_put_string(op, "op", "abort");
1213 json_array_add(operations, op);
1217 txn->status = TXN_UNCHANGED;
1218 json_destroy(operations);
1219 } else if (!jsonrpc_session_send(
1221 jsonrpc_create_request(
1222 "transact", operations, &txn->request_id))) {
1223 hmap_insert(&txn->idl->outstanding_txns, &txn->hmap_node,
1224 json_hash(txn->request_id, 0));
1226 txn->status = TXN_INCOMPLETE;
1229 ovsdb_idl_txn_disassemble(txn);
1234 ovsdb_idl_txn_get_increment_new_value(const struct ovsdb_idl_txn *txn)
1236 assert(txn->status == TXN_SUCCESS);
1237 return txn->inc_new_value;
1241 ovsdb_idl_txn_abort(struct ovsdb_idl_txn *txn)
1243 ovsdb_idl_txn_disassemble(txn);
1244 if (txn->status == TXN_INCOMPLETE) {
1245 txn->status = TXN_ABORTED;
1250 ovsdb_idl_txn_get_error(const struct ovsdb_idl_txn *txn)
1252 if (txn->status != TXN_ERROR) {
1253 return ovsdb_idl_txn_status_to_string(txn->status);
1254 } else if (txn->error) {
1257 return "no error details available";
1262 ovsdb_idl_txn_set_error_json(struct ovsdb_idl_txn *txn,
1263 const struct json *json)
1265 if (txn->error == NULL) {
1266 txn->error = json_to_string(json, JSSF_SORT);
1270 /* For transaction 'txn' that completed successfully, finds and returns the
1271 * permanent UUID that the database assigned to a newly inserted row, given the
1272 * 'uuid' that ovsdb_idl_txn_insert() assigned locally to that row.
1274 * Returns NULL if 'uuid' is not a UUID assigned by ovsdb_idl_txn_insert() or
1275 * if it was assigned by that function and then deleted by
1276 * ovsdb_idl_txn_delete() within the same transaction. (Rows that are inserted
1277 * and then deleted within a single transaction are never sent to the database
1278 * server, so it never assigns them a permanent UUID.) */
1280 ovsdb_idl_txn_get_insert_uuid(const struct ovsdb_idl_txn *txn,
1281 const struct uuid *uuid)
1283 const struct ovsdb_idl_txn_insert *insert;
1285 assert(txn->status == TXN_SUCCESS || txn->status == TXN_UNCHANGED);
1286 HMAP_FOR_EACH_IN_BUCKET (insert, struct ovsdb_idl_txn_insert, hmap_node,
1287 uuid_hash(uuid), &txn->inserted_rows) {
1288 if (uuid_equals(uuid, &insert->dummy)) {
1289 return &insert->real;
1296 ovsdb_idl_txn_complete(struct ovsdb_idl_txn *txn,
1297 enum ovsdb_idl_txn_status status)
1299 txn->status = status;
1300 hmap_remove(&txn->idl->outstanding_txns, &txn->hmap_node);
1304 ovsdb_idl_txn_read(const struct ovsdb_idl_row *row,
1305 const struct ovsdb_idl_column *column,
1306 struct ovsdb_datum *datum)
1308 const struct ovsdb_idl_table_class *class = row->table->class;
1309 size_t column_idx = column - class->columns;
1311 assert(row->new != NULL);
1312 if (row->written && bitmap_is_set(row->written, column_idx)) {
1313 ovsdb_datum_clone(datum, &row->new[column_idx], &column->type);
1314 } else if (row->old) {
1315 ovsdb_datum_clone(datum, &row->old[column_idx], &column->type);
1317 ovsdb_datum_init_default(datum, &column->type);
1322 ovsdb_idl_txn_write(const struct ovsdb_idl_row *row_,
1323 const struct ovsdb_idl_column *column,
1324 struct ovsdb_datum *datum)
1326 struct ovsdb_idl_row *row = (struct ovsdb_idl_row *) row_;
1327 const struct ovsdb_idl_table_class *class = row->table->class;
1328 size_t column_idx = column - class->columns;
1330 assert(row->new != NULL);
1331 assert(column_idx < class->n_columns);
1332 if (hmap_node_is_null(&row->txn_node)) {
1333 hmap_insert(&row->table->idl->txn->txn_rows, &row->txn_node,
1334 uuid_hash(&row->uuid));
1336 if (row->old == row->new) {
1337 row->new = xmalloc(class->n_columns * sizeof *row->new);
1339 if (!row->written) {
1340 row->written = bitmap_allocate(class->n_columns);
1342 if (bitmap_is_set(row->written, column_idx)) {
1343 ovsdb_datum_destroy(&row->new[column_idx], &column->type);
1345 bitmap_set1(row->written, column_idx);
1347 row->new[column_idx] = *datum;
1348 (column->unparse)(row);
1349 (column->parse)(row, &row->new[column_idx]);
1353 ovsdb_idl_txn_verify(const struct ovsdb_idl_row *row_,
1354 const struct ovsdb_idl_column *column)
1356 struct ovsdb_idl_row *row = (struct ovsdb_idl_row *) row_;
1357 const struct ovsdb_idl_table_class *class = row->table->class;
1358 size_t column_idx = column - class->columns;
1360 assert(row->new != NULL);
1362 || (row->written && bitmap_is_set(row->written, column_idx))) {
1366 if (hmap_node_is_null(&row->txn_node)) {
1367 hmap_insert(&row->table->idl->txn->txn_rows, &row->txn_node,
1368 uuid_hash(&row->uuid));
1370 if (!row->prereqs) {
1371 row->prereqs = bitmap_allocate(class->n_columns);
1373 bitmap_set1(row->prereqs, column_idx);
1377 ovsdb_idl_txn_delete(const struct ovsdb_idl_row *row_)
1379 struct ovsdb_idl_row *row = (struct ovsdb_idl_row *) row_;
1381 assert(row->new != NULL);
1383 ovsdb_idl_row_unparse(row);
1384 ovsdb_idl_row_clear_new(row);
1385 assert(!row->prereqs);
1386 hmap_remove(&row->table->rows, &row->hmap_node);
1387 hmap_remove(&row->table->idl->txn->txn_rows, &row->txn_node);
1391 if (hmap_node_is_null(&row->txn_node)) {
1392 hmap_insert(&row->table->idl->txn->txn_rows, &row->txn_node,
1393 uuid_hash(&row->uuid));
1395 ovsdb_idl_row_clear_new(row);
1399 const struct ovsdb_idl_row *
1400 ovsdb_idl_txn_insert(struct ovsdb_idl_txn *txn,
1401 const struct ovsdb_idl_table_class *class)
1403 struct ovsdb_idl_row *row = ovsdb_idl_row_create__(class);
1404 uuid_generate(&row->uuid);
1405 row->table = ovsdb_idl_table_from_class(txn->idl, class);
1406 row->new = xmalloc(class->n_columns * sizeof *row->new);
1407 row->written = bitmap_allocate(class->n_columns);
1408 hmap_insert(&row->table->rows, &row->hmap_node, uuid_hash(&row->uuid));
1409 hmap_insert(&txn->txn_rows, &row->txn_node, uuid_hash(&row->uuid));
1414 ovsdb_idl_txn_abort_all(struct ovsdb_idl *idl)
1416 struct ovsdb_idl_txn *txn;
1418 HMAP_FOR_EACH (txn, struct ovsdb_idl_txn, hmap_node,
1419 &idl->outstanding_txns) {
1420 ovsdb_idl_txn_complete(txn, TXN_TRY_AGAIN);
1424 static struct ovsdb_idl_txn *
1425 ovsdb_idl_txn_find(struct ovsdb_idl *idl, const struct json *id)
1427 struct ovsdb_idl_txn *txn;
1429 HMAP_FOR_EACH_WITH_HASH (txn, struct ovsdb_idl_txn, hmap_node,
1430 json_hash(id, 0), &idl->outstanding_txns) {
1431 if (json_equal(id, txn->request_id)) {
1439 check_json_type(const struct json *json, enum json_type type, const char *name)
1442 VLOG_WARN_RL(&syntax_rl, "%s is missing", name);
1444 } else if (json->type != type) {
1445 VLOG_WARN_RL(&syntax_rl, "%s is %s instead of %s",
1446 name, json_type_to_string(json->type),
1447 json_type_to_string(type));
1455 ovsdb_idl_txn_process_inc_reply(struct ovsdb_idl_txn *txn,
1456 const struct json_array *results)
1458 struct json *count, *rows, *row, *column;
1459 struct shash *mutate, *select;
1461 if (txn->inc_index + 2 > results->n) {
1462 VLOG_WARN_RL(&syntax_rl, "reply does not contain enough operations "
1463 "for increment (has %u, needs %u)",
1464 results->n, txn->inc_index + 2);
1468 /* We know that this is a JSON object because the loop in
1469 * ovsdb_idl_txn_process_reply() checked. */
1470 mutate = json_object(results->elems[txn->inc_index]);
1471 count = shash_find_data(mutate, "count");
1472 if (!check_json_type(count, JSON_INTEGER, "\"mutate\" reply \"count\"")) {
1475 if (count->u.integer != 1) {
1476 VLOG_WARN_RL(&syntax_rl,
1477 "\"mutate\" reply \"count\" is %"PRId64" instead of 1",
1482 select = json_object(results->elems[txn->inc_index + 1]);
1483 rows = shash_find_data(select, "rows");
1484 if (!check_json_type(rows, JSON_ARRAY, "\"select\" reply \"rows\"")) {
1487 if (rows->u.array.n != 1) {
1488 VLOG_WARN_RL(&syntax_rl, "\"select\" reply \"rows\" has %u elements "
1493 row = rows->u.array.elems[0];
1494 if (!check_json_type(row, JSON_OBJECT, "\"select\" reply row")) {
1497 column = shash_find_data(json_object(row), txn->inc_column);
1498 if (!check_json_type(column, JSON_INTEGER,
1499 "\"select\" reply inc column")) {
1502 txn->inc_new_value = column->u.integer;
1507 ovsdb_idl_txn_process_insert_reply(struct ovsdb_idl_txn_insert *insert,
1508 const struct json_array *results)
1510 static const struct ovsdb_base_type uuid_type = OVSDB_BASE_UUID_INIT;
1511 struct ovsdb_error *error;
1512 struct json *json_uuid;
1513 union ovsdb_atom uuid;
1514 struct shash *reply;
1516 if (insert->op_index >= results->n) {
1517 VLOG_WARN_RL(&syntax_rl, "reply does not contain enough operations "
1518 "for insert (has %u, needs %u)",
1519 results->n, insert->op_index);
1523 /* We know that this is a JSON object because the loop in
1524 * ovsdb_idl_txn_process_reply() checked. */
1525 reply = json_object(results->elems[insert->op_index]);
1526 json_uuid = shash_find_data(reply, "uuid");
1527 if (!check_json_type(json_uuid, JSON_ARRAY, "\"insert\" reply \"uuid\"")) {
1531 error = ovsdb_atom_from_json(&uuid, &uuid_type, json_uuid, NULL);
1533 char *s = ovsdb_error_to_string(error);
1534 VLOG_WARN_RL(&syntax_rl, "\"insert\" reply \"uuid\" is not a JSON "
1540 insert->real = uuid.uuid;
1546 ovsdb_idl_txn_process_reply(struct ovsdb_idl *idl,
1547 const struct jsonrpc_msg *msg)
1549 struct ovsdb_idl_txn *txn;
1550 enum ovsdb_idl_txn_status status;
1552 txn = ovsdb_idl_txn_find(idl, msg->id);
1557 if (msg->type == JSONRPC_ERROR) {
1559 } else if (msg->result->type != JSON_ARRAY) {
1560 VLOG_WARN_RL(&syntax_rl, "reply to \"transact\" is not JSON array");
1563 struct json_array *ops = &msg->result->u.array;
1564 int hard_errors = 0;
1565 int soft_errors = 0;
1568 for (i = 0; i < ops->n; i++) {
1569 struct json *op = ops->elems[i];
1571 if (op->type == JSON_NULL) {
1572 /* This isn't an error in itself but indicates that some prior
1573 * operation failed, so make sure that we know about it. */
1575 } else if (op->type == JSON_OBJECT) {
1578 error = shash_find_data(json_object(op), "error");
1580 if (error->type == JSON_STRING) {
1581 if (!strcmp(error->u.string, "timed out")) {
1583 } else if (strcmp(error->u.string, "aborted")) {
1585 ovsdb_idl_txn_set_error_json(txn, op);
1589 ovsdb_idl_txn_set_error_json(txn, op);
1590 VLOG_WARN_RL(&syntax_rl,
1591 "\"error\" in reply is not JSON string");
1596 ovsdb_idl_txn_set_error_json(txn, op);
1597 VLOG_WARN_RL(&syntax_rl,
1598 "operation reply is not JSON null or object");
1602 if (!soft_errors && !hard_errors) {
1603 struct ovsdb_idl_txn_insert *insert;
1605 if (txn->inc_table && !ovsdb_idl_txn_process_inc_reply(txn, ops)) {
1609 HMAP_FOR_EACH (insert, struct ovsdb_idl_txn_insert, hmap_node,
1610 &txn->inserted_rows) {
1611 if (!ovsdb_idl_txn_process_insert_reply(insert, ops)) {
1617 status = (hard_errors ? TXN_ERROR
1618 : soft_errors ? TXN_TRY_AGAIN
1622 ovsdb_idl_txn_complete(txn, status);
1626 struct ovsdb_idl_txn *
1627 ovsdb_idl_txn_get(const struct ovsdb_idl_row *row)
1629 struct ovsdb_idl_txn *txn = row->table->idl->txn;
1630 assert(txn != NULL);