Skip to content

Commit

Permalink
Removed encryption migration optimized search for dedup blocks as thi…
Browse files Browse the repository at this point in the history
…s creates slowness and high load when there are many same blocks.
  • Loading branch information
wamdam committed Oct 16, 2020
1 parent e806aff commit 09018ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
backy2 (2.13.3) unstable; urgency=low

* Removed encryption migration optimized search for dedup blocks as
this creates slowness and high load when there are many same blocks.

-- Daniel Kraft <[email protected]> Tue, 16 Oct 2020 12:29:21 +0200


backy2 (2.13.2) unstable; urgency=low

* Better logging. Now we have stderr for ERRORs and above and we don't show
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
from setuptools import setup, find_packages

version = '2.13.2'
version = '2.13.3'

setup(name='backy2',
version=version,
Expand Down
14 changes: 2 additions & 12 deletions src/backy2/meta_backends/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,18 +488,8 @@ def get_block(self, uid):
return self.session.query(Block).filter_by(uid=uid).first()


def get_block_by_checksum(self, checksum, preferred_encryption_version):
# there's this sql: order by field=value, field in order to get the specific value on top.
# Too bad, sqlalchemy does not support this (yes, I tried sqlalchemy.func.field). So we have
# to do this in python. Not too bad as there shouldn't be too many encryption versioned
# blocks of the same checksum.
# Here we prefer the block with preferred_encryption_version and next the highest encryption
# version number available, then decending.
results = sorted(self.session.query(Block).filter_by(checksum=checksum, valid=1).all(), key=lambda b: 100000 if b.enc_version==preferred_encryption_version else b.enc_version, reverse=True)
if not results:
return None
else:
return results[0]
def get_block_by_checksum(self, checksum, encryption_version):
return self.session.query(Block).filter_by(checksum=checksum, enc_version=encryption_version, valid=1).first()


def get_blocks_by_version(self, version_uid):
Expand Down

0 comments on commit 09018ce

Please sign in to comment.