exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

0002-work_shards.sql (1995B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2014--2022 Taler Systems SA
      4 --
      5 -- TALER is free software; you can redistribute it and/or modify it under the
      6 -- terms of the GNU General Public License as published by the Free Software
      7 -- Foundation; either version 3, or (at your option) any later version.
      8 --
      9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11 -- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 --
     13 -- You should have received a copy of the GNU General Public License along with
     14 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 --
     16 
     17 CREATE TABLE work_shards
     18   (shard_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
     19   ,last_attempt INT8 NOT NULL
     20   ,start_row INT8 NOT NULL
     21   ,end_row INT8 NOT NULL
     22   ,completed BOOLEAN NOT NULL DEFAULT FALSE
     23   ,job_name TEXT NOT NULL
     24   ,PRIMARY KEY (job_name, start_row)
     25   );
     26 COMMENT ON TABLE work_shards
     27   IS 'coordinates work between multiple processes working on the same job';
     28 COMMENT ON COLUMN work_shards.shard_serial_id
     29   IS 'unique serial number identifying the shard';
     30 COMMENT ON COLUMN work_shards.last_attempt
     31   IS 'last time a worker attempted to work on the shard';
     32 COMMENT ON COLUMN work_shards.completed
     33   IS 'set to TRUE once the shard is finished by a worker';
     34 COMMENT ON COLUMN work_shards.start_row
     35   IS 'row at which the shard scope starts, inclusive';
     36 COMMENT ON COLUMN work_shards.end_row
     37   IS 'row at which the shard scope ends, exclusive';
     38 COMMENT ON COLUMN work_shards.job_name
     39   IS 'unique name of the job the workers on this shard are performing';
     40 
     41 CREATE INDEX work_shards_by_job_name_completed_last_attempt_index
     42   ON work_shards
     43   (job_name
     44   ,completed
     45   ,last_attempt ASC
     46   );
     47 
     48 CREATE INDEX work_shards_by_end_row_index
     49   ON work_shards
     50   (end_row DESC);
     51 
     52 CREATE INDEX work_shards_by_rows
     53   ON work_shards
     54   (job_name
     55   ,start_row
     56   ,end_row);