From 0d30101d7c799cd667ddaccdeffe5f061d6010db Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sat, 28 May 2016 11:41:19 -0700 Subject: [PATCH] SCHEMA CHANGE: add 'request_id' to nameplates table This will be useful for the upcoming "persistent wormhole" mode. A client might send an allocation request, crash/terminate before receiving a response, then restart, then re-send the request. If the server sees a request with the same request_id a previous request, it can return the same nameplate. We'll need code changes on both sides to support this (nothing sends or checks request_id yet), but this lands the schema change early to reduce future disruption. --- src/wormhole/server/db-schemas/v2.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wormhole/server/db-schemas/v2.sql b/src/wormhole/server/db-schemas/v2.sql index b436897..3ff6e58 100644 --- a/src/wormhole/server/db-schemas/v2.sql +++ b/src/wormhole/server/db-schemas/v2.sql @@ -18,6 +18,7 @@ CREATE TABLE `nameplates` `mailbox_id` VARCHAR, -- really a foreign key `side1` VARCHAR, -- side name, or NULL `side2` VARCHAR, -- side name, or NULL + `request_id` VARCHAR, -- from 'allocate' message, for future deduplication `crowded` BOOLEAN, -- at some point, three or more sides were involved `updated` INTEGER, -- time of last activity, used for pruning -- timing data @@ -27,6 +28,7 @@ CREATE TABLE `nameplates` CREATE INDEX `nameplates_idx` ON `nameplates` (`app_id`, `id`); CREATE INDEX `nameplates_updated_idx` ON `nameplates` (`app_id`, `updated`); CREATE INDEX `nameplates_mailbox_idx` ON `nameplates` (`app_id`, `mailbox_id`); +CREATE INDEX `nameplates_request_idx` ON `nameplates` (`app_id`, `request_id`); -- Clients exchange messages through a "mailbox", which has a long (randomly -- unique) identifier and a queue of messages.