From 1b1d2e6daa563cc91f974ffdc082fb3a8b424801 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 31 Dec 2017 21:15:58 -0800 Subject: ovsdb: Introduce experimental support for clustered databases. This commit adds support for OVSDB clustering via Raft. Please read ovsdb(7) for information on how to set up a clustered database. It is simple and boils down to running "ovsdb-tool create-cluster" on one server and "ovsdb-tool join-cluster" on each of the others and then starting ovsdb-server in the usual way on all of them. One you have a clustered database, you configure ovn-controller and ovn-northd to use it by pointing them to all of the servers, e.g. where previously you might have said "tcp:1.2.3.4" was the database server, now you say that it is "tcp:1.2.3.4,tcp:5.6.7.8,tcp:9.10.11.12". This also adds support for database clustering to ovs-sandbox. Acked-by: Justin Pettit Tested-by: aginwala Signed-off-by: Ben Pfaff --- ovsdb/trigger.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'ovsdb/trigger.h') diff --git a/ovsdb/trigger.h b/ovsdb/trigger.h index a6c10e012..79af7f6be 100644 --- a/ovsdb/trigger.h +++ b/ovsdb/trigger.h @@ -20,13 +20,35 @@ struct ovsdb; +/* Triggers have the following states: + * + * - Initialized (reply == NULL, progress == NULL): Executing the trigger + * can keep it in the initialized state, if it has a "wait" condition that + * isn't met. Executing the trigger can also yield an error, in which + * case it transitions to "complete". Otherwise, execution yields a + * transaction, which the database attempts to commit. If the transaction + * completes immediately and synchronously, then the trigger transitions + * to the "complete" state. If the transaction requires some time to + * complete, it transitions to the "committing" state. + * + * - Committing (reply != NULL, progress != NULL): The transaction is + * committing. If it succeeds, or if it fails permanently, then the + * trigger transitions to "complete". If it fails temporarily + * (e.g. because someone else committed to cluster-based storage before we + * did), then we transition back to "initialized" to try again. + * + * - Complete (reply != NULL, progress == NULL): The transaction is done + * and either succeeded or failed. + */ struct ovsdb_trigger { + /* In "initialized" or "committing" state, in db->triggers. + * In "complete", in session->completions. */ + struct ovs_list node; struct ovsdb_session *session; /* Session that owns this trigger. */ struct ovsdb *db; /* Database on which trigger acts. */ - struct ovs_list node; /* !result: in db->triggers; - * result: in session->completions. */ struct jsonrpc_msg *request; /* Database request. */ struct jsonrpc_msg *reply; /* Result (null if none yet). */ + struct ovsdb_txn_progress *progress; long long int created; /* Time created. */ long long int timeout_msec; /* Max wait duration. */ bool read_only; /* Database is in read only mode. */ @@ -42,6 +64,7 @@ void ovsdb_trigger_destroy(struct ovsdb_trigger *); bool ovsdb_trigger_is_complete(const struct ovsdb_trigger *); struct jsonrpc_msg *ovsdb_trigger_steal_reply(struct ovsdb_trigger *); +void ovsdb_trigger_cancel(struct ovsdb_trigger *, const char *reason); void ovsdb_trigger_prereplace_db(struct ovsdb_trigger *); -- cgit v1.2.1