Showing 1 of 7 files from the diff.

@@ -10,6 +10,7 @@
Loading
10 10
import re
11 11
import select
12 12
import sys
13 +
import time
13 14
14 15
import click
15 16
import psycopg2
@@ -32,7 +33,7 @@
Loading
32 33
from .node import traverse_breadth_first, traverse_post_order, Tree
33 34
from .querybuilder import QueryBuilder
34 35
from .redisqueue import RedisQueue
35 -
from .settings import POLL_TIMEOUT
36 +
from .settings import POLL_TIMEOUT, REPLICATION_SLOT_CLEANUP_INTERVAL
36 37
from .utils import (
37 38
    get_config,
38 39
    get_private_keys,
@@ -65,6 +66,7 @@
Loading
65 66
        self.es = ElasticHelper()
66 67
        self.__name = f"{self.database}_{self.index}"
67 68
        self._checkpoint = None
69 +
        self._truncate = False
68 70
        self.verbose = verbose
69 71
        self._checkpoint_file = f".{self.__name}"
70 72
        self.redis = RedisQueue(self.__name)
@@ -879,6 +881,16 @@
Loading
879 881
        self.sync(txmin=txmin, txmax=txmax)
880 882
        # now sync up to txmax to capture everything we might have missed
881 883
        self.logical_slot_changes(txmin=txmin, txmax=txmax)
884 +
        self._truncate = True
885 +
886 +
    @threaded
887 +
    def truncate_slots(self):
888 +
        """Truncate the logical replication slot."""
889 +
        while True:
890 +
            if self._truncate:
891 +
                logger.debug(f'Truncating replication slot: {self.__name}')
892 +
                self.logical_slot_get_changes(self.__name, upto_nchanges=None)
893 +
            time.sleep(REPLICATION_SLOT_CLEANUP_INTERVAL)
882 894
883 895
    def receive(self):
884 896
        """
@@ -901,6 +913,9 @@
Loading
901 913
        # poll Redis and populate Elasticsearch
902 914
        self.poll_redis()
903 915
916 +
        # start a background worker thread to cleanup the replication slot
917 +
        self.truncate_slots()
918 +
904 919
905 920
@click.command()
906 921
@click.option(
Files Coverage
pgsync 68.75%
tests/__init__.py 100.00%
Project Totals (10 files) 68.83%
codecov-umbrella
Build #370982789 -
unittests
codecov-umbrella
Build #370982789 -
unittests
codecov-umbrella
Build #370982789 -
unittests
codecov-umbrella
Build #370982789 -
unittests
1
coverage:
2
  status:
3
    project:
4
      default:
5
        threshold: 70%
6

7
codecov:
8
  archive: 
9
    uploads: false
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading