in core/lib/payload/copy.py [0:0]
def checksum_for_changes(self, single_trx=False):
"""
This checksum will only run against changes made between last full
table checksum and before swap table
We assume A transaction has been opened before calling this function,
and changes has been replayed
@param single_trx: whether skip the commit call after checksum old
table. This can prevent opening a transaction for too long when we
don't actually need it
@type single_trx: bool
"""
if self.eliminate_dups:
log.warning("Skip checksum, because --elimiate-duplicate " "specified")
return
elif not self.need_checksum_for_changes():
return
# Because chunk checksum use old pk combination for searching row
# If we don't have a pk/uk on old table then it'll be very slow, so we
# have to skip here
elif self.is_full_table_dump:
return
else:
log.info(
"Running checksum for rows have been changed since "
"last checksum from change ID: {}".format(self.last_checksumed_id)
)
start_time = time.time()
old_table_checksum = self.checksum_by_replay_chunk(self.table_name)
# Checksum for the __new table should be issued inside the transcation
# too. Otherwise those invisible gaps in the __chg table will show
# up when calculating checksums
new_table_checksum = self.checksum_by_replay_chunk(self.new_table_name)
# After calculation checksums from both tables, we now can close the
# transcation, if we want
if not single_trx:
self.commit()
self.compare_checksum(old_table_checksum, new_table_checksum)
self.last_checksumed_id = self.last_replayed_id
self.stats["time_in_delta_checksum"] = self.stats.setdefault(
"time_in_delta_checksum", 0
) + (time.time() - start_time)