diff options
| author | Marko Kreen | 2013-02-14 14:37:39 +0000 |
|---|---|---|
| committer | Marko Kreen | 2013-02-14 14:37:39 +0000 |
| commit | 1e5cce43e847c7b154c1ef9ce3ea57ec0850e224 (patch) | |
| tree | 162911bd2dc413c984cd321b452a02002471a2a7 | |
| parent | 11a8620012159ba18a177132125c33bef00b56f9 (diff) | |
| parent | 8276313d5b8e9fdb547f231bbc273876f5f025b2 (diff) | |
Merge remote-tracking branch 'tarvip/master'
| -rwxr-xr-x | python/londiste.py | 8 | ||||
| -rw-r--r-- | python/londiste/compare.py | 14 | ||||
| -rw-r--r-- | python/londiste/handlers/dispatch.py | 6 | ||||
| -rw-r--r-- | python/pgq/cascade/admin.py | 7 | ||||
| -rw-r--r-- | python/skytools/scripting.py | 5 |
5 files changed, 26 insertions, 14 deletions
diff --git a/python/londiste.py b/python/londiste.py index fb230f23..272b824c 100755 --- a/python/londiste.py +++ b/python/londiste.py @@ -86,7 +86,7 @@ class Londiste(skytools.DBScript): londiste.Replicator(self.full_args) def init_optparse(self, parser=None): - p = skytools.DBScript.init_optparse(self, parser) + p = super(Londiste, self).init_optparse(parser) p.set_usage(command_usage.strip()) g = optparse.OptionGroup(p, "options for cascading") @@ -105,6 +105,7 @@ class Londiste(skytools.DBScript): g.add_option("--sync-watermark", help = "create-branch: list of node names to sync wm with") p.add_option_group(g) + g = optparse.OptionGroup(p, "repair queue position") g.add_option("--rewind", action = "store_true", help = "change queue position according to destination") @@ -149,11 +150,13 @@ class Londiste(skytools.DBScript): help="max number of parallel copy processes") p.add_option_group(g) - g = optparse.OptionGroup(p, "other options options") + g = optparse.OptionGroup(p, "other options") g.add_option("--force", action="store_true", help = "add: ignore table differences, repair: ignore lag") g.add_option("--apply", action = "store_true", help="repair: apply fixes automatically") + p.add_option("--count-only", action="store_true", + help="compare: just count rows, do not compare data") p.add_option_group(g) return p @@ -161,4 +164,3 @@ class Londiste(skytools.DBScript): if __name__ == '__main__': script = Londiste(sys.argv[1:]) script.start() - diff --git a/python/londiste/compare.py b/python/londiste/compare.py index a92ae513..83dac2e4 100644 --- a/python/londiste/compare.py +++ b/python/londiste/compare.py @@ -35,7 +35,9 @@ class Comparator(Syncer): # get sane query v1 = src_db.server_version v2 = dst_db.server_version - if v1 < 80300 or v2 < 80300: + if self.options.count_only: + q = "select count(1) as cnt from only _TABLE_" + elif v1 < 80300 or v2 < 80300: # 8.2- does not have record to text and text to bit casts, so we need to use a bit of evil hackery q = "select count(1) as cnt, sum(bit_in(textout('x'||substr(md5(textin(record_out(_COLS_))),1,16)), 0, 64)::bigint) as chksum from only _TABLE_" elif (v1 < 80400 or v2 < 80400) and v1 != v2: @@ -54,7 +56,9 @@ class Comparator(Syncer): if dst_where: dst_q = dst_q + " WHERE " + dst_where - f = "%(cnt)d rows, checksum=%(chksum)s" + f = "%(cnt)d rows" + if not self.options.count_only: + f += ", checksum=%(chksum)s" f = self.cf.get('compare_fmt', f) self.log.debug("srcdb: " + src_q) @@ -111,6 +115,12 @@ class Comparator(Syncer): return common + def init_optparse(self, p=None): + """Initialize cmdline switches.""" + p = super(Comparator, self).init_optparse(p) + p.add_option("--count-only", action="store_true", help="just count rows, do not compare data") + return p + if __name__ == '__main__': script = Comparator(sys.argv[1:]) script.start() diff --git a/python/londiste/handlers/dispatch.py b/python/londiste/handlers/dispatch.py index 9acc43ce..17e88a24 100644 --- a/python/londiste/handlers/dispatch.py +++ b/python/londiste/handlers/dispatch.py @@ -90,7 +90,7 @@ part_template: row_mode: how rows are applied to target table * plain - each event creates SQL statement to run (default) - * keep_latest - change updates to DELETE + INSERT, ignore deletes + * keep_latest - change updates to DELETE + INSERT * keep_all - change updates to inserts, ignore deletes event_types: @@ -592,7 +592,7 @@ class KeepLatestRowHandler(RowHandler): def process(self, table, op, row): """Keep latest row version. - Updates are changed to delete + insert, deletes are ignored. + Updates are changed to delete + insert Makes sense only for partitioned tables. """ if op == 'U': @@ -600,6 +600,8 @@ class KeepLatestRowHandler(RowHandler): RowHandler.process(self, table, 'I', row) elif op == 'I': RowHandler.process(self, table, 'I', row) + elif op == 'D': + RowHandler.process(self, table, 'D', row) ROW_HANDLERS = {'plain': RowHandler, diff --git a/python/pgq/cascade/admin.py b/python/pgq/cascade/admin.py index 9e789fb1..200a1015 100644 --- a/python/pgq/cascade/admin.py +++ b/python/pgq/cascade/admin.py @@ -29,7 +29,6 @@ Node Initialization: create-leaf NAME PUBLIC_CONNSTR --provider=<public_connstr> Initializes node. - Node Administration: pause Pause node worker. resume Resume node worker. @@ -54,11 +53,9 @@ Cascade layout change: tag-alive NODE .. Tag node as alive - """ standalone_usage = """ - setadm extra switches: pause/resume/change-provider: @@ -88,8 +85,8 @@ class CascadeAdmin(skytools.AdminScript): """Add SetAdmin switches to parser.""" p = skytools.AdminScript.init_optparse(self, parser) - usage = command_usage.strip() + standalone_usage - p.set_usage(usage) + usage = command_usage + standalone_usage + p.set_usage(usage.strip()) g = optparse.OptionGroup(p, "actual queue admin options") g.add_option("--connstr", action="store_true", diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py index fd7805d8..23c3ef56 100644 --- a/python/skytools/scripting.py +++ b/python/skytools/scripting.py @@ -381,11 +381,11 @@ class BaseScript(object): parse command line arguments. Note that it can be overridden both directions - either DBScript - will initialize a instance and passes to user code or user can + will initialize an instance and pass it to user code or user can initialize and then pass to DBScript.init_optparse(). @param parser: optional OptionParser() instance, - where DBScript should attachs its own arguments. + where DBScript should attach its own arguments. @return: initialized OptionParser() instance. """ if parser: @@ -393,6 +393,7 @@ class BaseScript(object): else: p = optparse.OptionParser() p.set_usage("%prog [options] INI") + # generic options p.add_option("-q", "--quiet", action="store_true", help = "log only errors and warnings") |
