Truncate events can be ignored on per handler basis.
Parameters:
encoding=ENC - Validate and fix incoming data from encoding.
Only 'utf8' is supported at the moment.
+ ignore_truncate=BOOL - Ignore truncate event. Default: 0; Values: 0,1.
"""
handler_name = 'londiste'
else:
self.encoding_validator = None
+ def get_config (self):
+ conf = BaseHandler.get_config(self)
+ conf.ignore_truncate = self.get_arg('ignore_truncate', [0, 1], 0)
+ return conf
+
def process_event(self, ev, sql_queue_func, arg):
row = self.parse_row_data(ev)
if len(ev.type) == 1:
* 0 - handle all events in the same way (default)
* 1 - ignore events coming for obsolete partitions
+ignore_truncate:
+ * 0 - process truncate event (default)
+ * 1 - ignore truncate event
+
encoding:
name of destination encoding. handler replaces all invalid encoding symbols
and logs them as warnings
hashfunc=NAME: function to use for hashing (default: partconf.get_hash_raw)
hashexpr=EXPR: full expression to use for hashing (deprecated)
encoding=ENC: validate and fix incoming data (only utf8 supported atm)
+ ignore_truncate=BOOL: ignore truncate event, default: 0, values: 0,1
On root node:
* Hash of key field will be added to ev_extra3.
self.current_event = None
def handle_data_event(self, ev, dst_curs):
- """handle one truncate event"""
+ """handle one data event"""
t = self.get_table_by_name(ev.extra1)
if not t or not t.interesting(ev, self.cur_tick, self.copy_thread, self.copy_table_name):
self.stat_increase('ignored_events')
fqname = skytools.quote_fqident(t.dest_table)
+ try:
+ p = self.used_plugins[ev.extra1]
+ except KeyError:
+ p = t.get_plugin()
+ self.used_plugins[ev.extra1] = p
+
+ if p.conf.get('ignore_truncate'):
+ self.log.info("ignoring truncate for %s", fqname)
+ return
+
#
# Always use CASCADE, because without it the
# operation cannot work with FKeys, on both