diff --git a/doc/source/deployment_guide.rst b/doc/source/deployment_guide.rst index 7aeb640aa4..0d520d6960 100644 --- a/doc/source/deployment_guide.rst +++ b/doc/source/deployment_guide.rst @@ -425,10 +425,10 @@ bind_ip 0.0.0.0 IP Address for server to bind to bind_port 6002 Port for server to bind to workers 1 Number of workers to fork user swift User to run as -db_preallocation on Normally Swift will try to preallocate disk - space for new SQLite databases to decrease - fragmentation (at the cost of disk usage). You - may turn this feature off here. +db_preallocation off If you don't mind the extra disk space usage in + overhead, you can turn this on to preallocate + disk space with SQLite databases to decrease + fragmentation. ================== ========== ============================================= [account-server] diff --git a/etc/account-server.conf-sample b/etc/account-server.conf-sample index 05599b637e..11943d366a 100644 --- a/etc/account-server.conf-sample +++ b/etc/account-server.conf-sample @@ -17,10 +17,9 @@ # log_statsd_port = 8125 # log_statsd_default_sample_rate = 1 # log_statsd_metric_prefix = -# Normally Swift will try to preallocate disk space for new SQLite databases to -# decrease fragmentation (at the cost of disk usage). You may turn this feature -# off here. -# db_preallocation = on +# If you don't mind the extra disk space usage in overhead, you can turn this +# on to preallocate disk space with SQLite databases to decrease fragmentation. +# db_preallocation = off [pipeline:main] pipeline = account-server diff --git a/etc/container-server.conf-sample b/etc/container-server.conf-sample index f84071babf..962013d6d1 100644 --- a/etc/container-server.conf-sample +++ b/etc/container-server.conf-sample @@ -20,10 +20,9 @@ # log_statsd_port = 8125 # log_statsd_default_sample_rate = 1 # log_statsd_metric_prefix = -# Normally Swift will try to preallocate disk space for new SQLite databases to -# decrease fragmentation (at the cost of disk usage). You may turn this feature -# off here. -# db_preallocation = on +# If you don't mind the extra disk space usage in overhead, you can turn this +# on to preallocate disk space with SQLite databases to decrease fragmentation. +# db_preallocation = off [pipeline:main] pipeline = container-server diff --git a/swift/account/auditor.py b/swift/account/auditor.py index 108085f471..7b9299ecc0 100644 --- a/swift/account/auditor.py +++ b/swift/account/auditor.py @@ -39,7 +39,7 @@ class AccountAuditor(Daemon): self.account_passes = 0 self.account_failures = 0 swift.common.db.DB_PREALLOCATION = \ - conf.get('db_preallocation', 't').lower() in TRUE_VALUES + conf.get('db_preallocation', 'f').lower() in TRUE_VALUES def _one_audit_pass(self, reported): all_locs = audit_location_generator(self.devices, diff --git a/swift/account/reaper.py b/swift/account/reaper.py index 28017e8042..fb229e3dc4 100644 --- a/swift/account/reaper.py +++ b/swift/account/reaper.py @@ -71,7 +71,7 @@ class AccountReaper(Daemon): sqrt(self.concurrency) self.container_pool = GreenPool(size=self.container_concurrency) swift.common.db.DB_PREALLOCATION = \ - conf.get('db_preallocation', 't').lower() in TRUE_VALUES + conf.get('db_preallocation', 'f').lower() in TRUE_VALUES self.delay_reaping = int(conf.get('delay_reaping') or 0) def get_account_ring(self): diff --git a/swift/account/server.py b/swift/account/server.py index a1497f9776..57db311588 100644 --- a/swift/account/server.py +++ b/swift/account/server.py @@ -55,7 +55,7 @@ class AccountController(object): self.auto_create_account_prefix = \ conf.get('auto_create_account_prefix') or '.' swift.common.db.DB_PREALLOCATION = \ - conf.get('db_preallocation', 't').lower() in TRUE_VALUES + conf.get('db_preallocation', 'f').lower() in TRUE_VALUES def _get_account_broker(self, drive, part, account): hsh = hash_path(account) diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py index 8f7dd5e8aa..ef9f17735c 100644 --- a/swift/common/db_replicator.py +++ b/swift/common/db_replicator.py @@ -122,7 +122,7 @@ class Replicator(Daemon): self.conn_timeout = float(conf.get('conn_timeout', 0.5)) self.reclaim_age = float(conf.get('reclaim_age', 86400 * 7)) swift.common.db.DB_PREALLOCATION = \ - conf.get('db_preallocation', 't').lower() in TRUE_VALUES + conf.get('db_preallocation', 'f').lower() in TRUE_VALUES self._zero_stats() def _zero_stats(self): diff --git a/swift/container/auditor.py b/swift/container/auditor.py index a69ebb3c3d..c9c2581182 100644 --- a/swift/container/auditor.py +++ b/swift/container/auditor.py @@ -40,7 +40,7 @@ class ContainerAuditor(Daemon): self.container_passes = 0 self.container_failures = 0 swift.common.db.DB_PREALLOCATION = \ - conf.get('db_preallocation', 't').lower() in TRUE_VALUES + conf.get('db_preallocation', 'f').lower() in TRUE_VALUES def _one_audit_pass(self, reported): all_locs = audit_location_generator(self.devices, diff --git a/swift/container/server.py b/swift/container/server.py index 8dcf12b97e..0281881163 100644 --- a/swift/container/server.py +++ b/swift/container/server.py @@ -69,7 +69,7 @@ class ContainerController(object): if conf.get('allow_versions', 'f').lower() in TRUE_VALUES: self.save_headers.append('x-versions-location') swift.common.db.DB_PREALLOCATION = \ - conf.get('db_preallocation', 't').lower() in TRUE_VALUES + conf.get('db_preallocation', 'f').lower() in TRUE_VALUES def _get_container_broker(self, drive, part, account, container): """ diff --git a/swift/container/sync.py b/swift/container/sync.py index 8d09a46a38..69216f65d5 100644 --- a/swift/container/sync.py +++ b/swift/container/sync.py @@ -180,7 +180,7 @@ class ContainerSync(Daemon): self._myips = whataremyips() self._myport = int(conf.get('bind_port', 6001)) swift.common.db.DB_PREALLOCATION = \ - conf.get('db_preallocation', 't').lower() in TRUE_VALUES + conf.get('db_preallocation', 'f').lower() in TRUE_VALUES def run_forever(self): """ diff --git a/swift/container/updater.py b/swift/container/updater.py index 74f30172ff..2b76512ba0 100644 --- a/swift/container/updater.py +++ b/swift/container/updater.py @@ -58,7 +58,7 @@ class ContainerUpdater(Daemon): float(conf.get('account_suppression_time', 60)) self.new_account_suppressions = None swift.common.db.DB_PREALLOCATION = \ - conf.get('db_preallocation', 't').lower() in TRUE_VALUES + conf.get('db_preallocation', 'f').lower() in TRUE_VALUES def get_account_ring(self): """Get the account ring. Load it if it hasn't been yet.""" diff --git a/test/unit/common/test_db.py b/test/unit/common/test_db.py index d6b141c466..678db619d4 100644 --- a/test/unit/common/test_db.py +++ b/test/unit/common/test_db.py @@ -100,9 +100,9 @@ class TestDatabaseBroker(unittest.TestCase): def test_DB_PREALLOCATION_setting(self): u = uuid4().hex b = DatabaseBroker(u) - self.assertRaises(OSError, b._preallocate) - swift.common.db.DB_PREALLOCATION = False b._preallocate() + swift.common.db.DB_PREALLOCATION = True + self.assertRaises(OSError, b._preallocate) def tearDown(self): rmtree(self.testdir, ignore_errors=1)