exchange

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

0013-work_shards.sql (1640B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2026 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 -- Track how far a worker has come *within* a shard, so that the work it
     18 -- committed can be recorded long before the shard as a whole is finished, and
     19 -- so that a worker picking the shard up later resumes instead of restarting.
     20 ALTER TABLE work_shards
     21   ADD COLUMN progress_row INT8;
     22 
     23 -- Existing rows have no recorded progress. Starting them over is always safe
     24 -- (every job using this table is idempotent, it just costs extra work), so
     25 -- point them at the beginning of their shard.
     26 UPDATE work_shards
     27    SET progress_row=start_row;
     28 
     29 ALTER TABLE work_shards
     30   ALTER COLUMN progress_row SET NOT NULL;
     31 
     32 COMMENT ON COLUMN work_shards.progress_row
     33   IS 'rows in [start_row,progress_row) of this shard have been processed and committed; equal to start_row while nothing has been done yet and to end_row once the shard is complete. Only ever moves forward, so a second worker that concurrently grabbed the same shard cannot rewind it.';