swift 2.31.1__py2.py3-none-any.whl → 2.32.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swift/cli/info.py +9 -2
- swift/cli/ringbuilder.py +5 -1
- swift/common/container_sync_realms.py +6 -7
- swift/common/daemon.py +7 -3
- swift/common/db.py +22 -7
- swift/common/db_replicator.py +19 -20
- swift/common/direct_client.py +63 -14
- swift/common/internal_client.py +24 -3
- swift/common/manager.py +43 -44
- swift/common/memcached.py +168 -74
- swift/common/middleware/__init__.py +4 -0
- swift/common/middleware/account_quotas.py +98 -40
- swift/common/middleware/backend_ratelimit.py +6 -4
- swift/common/middleware/crossdomain.py +21 -8
- swift/common/middleware/listing_formats.py +26 -38
- swift/common/middleware/proxy_logging.py +12 -9
- swift/common/middleware/s3api/controllers/bucket.py +8 -2
- swift/common/middleware/s3api/s3api.py +9 -4
- swift/common/middleware/s3api/s3request.py +32 -24
- swift/common/middleware/s3api/s3response.py +10 -1
- swift/common/middleware/tempauth.py +9 -10
- swift/common/middleware/versioned_writes/__init__.py +0 -3
- swift/common/middleware/versioned_writes/object_versioning.py +22 -5
- swift/common/middleware/x_profile/html_viewer.py +1 -1
- swift/common/middleware/xprofile.py +5 -0
- swift/common/request_helpers.py +1 -2
- swift/common/ring/ring.py +22 -19
- swift/common/swob.py +2 -1
- swift/common/{utils.py → utils/__init__.py} +610 -1146
- swift/common/utils/ipaddrs.py +256 -0
- swift/common/utils/libc.py +345 -0
- swift/common/utils/timestamp.py +399 -0
- swift/common/wsgi.py +70 -39
- swift/container/backend.py +106 -38
- swift/container/server.py +11 -2
- swift/container/sharder.py +34 -15
- swift/locale/de/LC_MESSAGES/swift.po +1 -320
- swift/locale/en_GB/LC_MESSAGES/swift.po +1 -347
- swift/locale/es/LC_MESSAGES/swift.po +1 -279
- swift/locale/fr/LC_MESSAGES/swift.po +1 -209
- swift/locale/it/LC_MESSAGES/swift.po +1 -207
- swift/locale/ja/LC_MESSAGES/swift.po +2 -278
- swift/locale/ko_KR/LC_MESSAGES/swift.po +3 -303
- swift/locale/pt_BR/LC_MESSAGES/swift.po +1 -204
- swift/locale/ru/LC_MESSAGES/swift.po +1 -203
- swift/locale/tr_TR/LC_MESSAGES/swift.po +1 -192
- swift/locale/zh_CN/LC_MESSAGES/swift.po +1 -192
- swift/locale/zh_TW/LC_MESSAGES/swift.po +1 -193
- swift/obj/diskfile.py +19 -6
- swift/obj/server.py +20 -6
- swift/obj/ssync_receiver.py +19 -9
- swift/obj/ssync_sender.py +10 -10
- swift/proxy/controllers/account.py +7 -7
- swift/proxy/controllers/base.py +374 -366
- swift/proxy/controllers/container.py +112 -53
- swift/proxy/controllers/obj.py +254 -390
- swift/proxy/server.py +3 -8
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-account-server +1 -1
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-container-server +1 -1
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-drive-audit +45 -14
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-object-server +1 -1
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-proxy-server +1 -1
- {swift-2.31.1.dist-info → swift-2.32.1.dist-info}/AUTHORS +4 -0
- {swift-2.31.1.dist-info → swift-2.32.1.dist-info}/METADATA +32 -35
- {swift-2.31.1.dist-info → swift-2.32.1.dist-info}/RECORD +103 -100
- {swift-2.31.1.dist-info → swift-2.32.1.dist-info}/WHEEL +1 -1
- {swift-2.31.1.dist-info → swift-2.32.1.dist-info}/entry_points.txt +0 -1
- swift-2.32.1.dist-info/pbr.json +1 -0
- swift-2.31.1.dist-info/pbr.json +0 -1
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-account-audit +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-account-auditor +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-account-info +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-account-reaper +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-account-replicator +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-config +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-container-auditor +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-container-info +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-container-reconciler +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-container-replicator +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-container-sharder +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-container-sync +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-container-updater +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-dispersion-populate +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-dispersion-report +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-form-signature +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-get-nodes +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-init +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-object-auditor +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-object-expirer +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-object-info +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-object-reconstructor +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-object-relinker +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-object-replicator +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-object-updater +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-oldies +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-orphans +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-recon +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-recon-cron +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-reconciler-enqueue +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-ring-builder +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-ring-builder-analyzer +0 -0
- {swift-2.31.1.data → swift-2.32.1.data}/scripts/swift-ring-composer +0 -0
- {swift-2.31.1.dist-info → swift-2.32.1.dist-info}/LICENSE +0 -0
- {swift-2.31.1.dist-info → swift-2.32.1.dist-info}/top_level.txt +0 -0
swift/container/backend.py
CHANGED
@@ -32,7 +32,7 @@ from swift.common.utils import Timestamp, encode_timestamps, \
|
|
32
32
|
decode_timestamps, extract_swift_bytes, storage_directory, hash_path, \
|
33
33
|
ShardRange, renamer, MD5_OF_EMPTY_STRING, mkdirs, get_db_files, \
|
34
34
|
parse_db_filename, make_db_file_path, split_path, RESERVED_BYTE, \
|
35
|
-
|
35
|
+
ShardRangeList, Namespace
|
36
36
|
from swift.common.db import DatabaseBroker, utf8encode, BROKER_TIMEOUT, \
|
37
37
|
zero_like, DatabaseAlreadyExists, SQLITE_ARG_LIMIT
|
38
38
|
|
@@ -446,7 +446,7 @@ class ContainerBroker(DatabaseBroker):
|
|
446
446
|
return UNSHARDED
|
447
447
|
if self.db_epoch != self.get_own_shard_range().epoch:
|
448
448
|
return UNSHARDED
|
449
|
-
if not self.
|
449
|
+
if not self.has_other_shard_ranges():
|
450
450
|
return COLLAPSED
|
451
451
|
return SHARDED
|
452
452
|
|
@@ -457,7 +457,7 @@ class ContainerBroker(DatabaseBroker):
|
|
457
457
|
"""
|
458
458
|
own_shard_range = self.get_own_shard_range()
|
459
459
|
if own_shard_range.state in ShardRange.CLEAVING_STATES:
|
460
|
-
return
|
460
|
+
return self.has_other_shard_ranges()
|
461
461
|
return False
|
462
462
|
|
463
463
|
def sharding_required(self):
|
@@ -523,7 +523,7 @@ class ContainerBroker(DatabaseBroker):
|
|
523
523
|
def storage_policy_index(self):
|
524
524
|
if not hasattr(self, '_storage_policy_index'):
|
525
525
|
self._storage_policy_index = \
|
526
|
-
self.
|
526
|
+
self._get_info()['storage_policy_index']
|
527
527
|
return self._storage_policy_index
|
528
528
|
|
529
529
|
@property
|
@@ -867,7 +867,7 @@ class ContainerBroker(DatabaseBroker):
|
|
867
867
|
Timestamp(info['put_timestamp']))
|
868
868
|
|
869
869
|
def is_empty_enough_to_reclaim(self):
|
870
|
-
if self.is_root_container() and (self.
|
870
|
+
if self.is_root_container() and (self.has_other_shard_ranges() or
|
871
871
|
self.get_db_state() == SHARDING):
|
872
872
|
return False
|
873
873
|
return self.empty()
|
@@ -1685,9 +1685,11 @@ class ContainerBroker(DatabaseBroker):
|
|
1685
1685
|
if ('no such table: %s' % SHARD_RANGE_TABLE) not in str(err):
|
1686
1686
|
raise
|
1687
1687
|
|
1688
|
-
def _get_shard_range_rows(self, connection=None,
|
1688
|
+
def _get_shard_range_rows(self, connection=None, marker=None,
|
1689
|
+
end_marker=None, includes=None,
|
1689
1690
|
include_deleted=False, states=None,
|
1690
|
-
include_own=False, exclude_others=False
|
1691
|
+
include_own=False, exclude_others=False,
|
1692
|
+
limit=None):
|
1691
1693
|
"""
|
1692
1694
|
Returns a list of shard range rows.
|
1693
1695
|
|
@@ -1696,19 +1698,36 @@ class ContainerBroker(DatabaseBroker):
|
|
1696
1698
|
``exclude_others=True``.
|
1697
1699
|
|
1698
1700
|
:param connection: db connection
|
1701
|
+
:param marker: restricts the returned list to rows whose namespace
|
1702
|
+
includes or is greater than the marker value. ``marker`` is ignored
|
1703
|
+
if ``includes`` is specified.
|
1704
|
+
:param end_marker: restricts the returned list to rows whose namespace
|
1705
|
+
includes or is less than the end_marker value. ``end_marker`` is
|
1706
|
+
ignored if ``includes`` is specified.
|
1699
1707
|
:param includes: restricts the returned list to the shard range that
|
1700
|
-
includes the given value
|
1701
|
-
|
1708
|
+
includes the given value; if ``includes`` is specified then
|
1709
|
+
``marker`` and ``end_marker`` are ignored, but other constraints
|
1710
|
+
are applied (e.g. ``exclude_others`` and ``include_deleted``).
|
1711
|
+
:param include_deleted: include rows marked as deleted.
|
1702
1712
|
:param states: include only rows matching the given state(s); can be an
|
1703
1713
|
int or a list of ints.
|
1704
1714
|
:param include_own: boolean that governs whether the row whose name
|
1705
1715
|
matches the broker's path is included in the returned list. If
|
1706
|
-
True, that row is included
|
1707
|
-
|
1716
|
+
True, that row is included unless it is excluded by other
|
1717
|
+
constraints (e.g. ``marker``, ``end_marker``, ``includes``). If
|
1718
|
+
False, that row is not included. Default is False.
|
1708
1719
|
:param exclude_others: boolean that governs whether the rows whose
|
1709
1720
|
names do not match the broker's path are included in the returned
|
1710
1721
|
list. If True, those rows are not included, otherwise they are
|
1711
1722
|
included. Default is False.
|
1723
|
+
:param limit: restricts the returned list to the given number of rows.
|
1724
|
+
Should be a whole number; negative values will be ignored.
|
1725
|
+
The ``limit`` parameter is useful to optimise a search
|
1726
|
+
when the maximum number of expected matching rows is known, and
|
1727
|
+
particularly when that maximum number is much less than the total
|
1728
|
+
number of rows in the DB. However, the DB search is not ordered and
|
1729
|
+
the subset of rows returned when ``limit`` is less than all
|
1730
|
+
possible matching rows is therefore unpredictable.
|
1712
1731
|
:return: a list of tuples.
|
1713
1732
|
"""
|
1714
1733
|
|
@@ -1741,11 +1760,20 @@ class ContainerBroker(DatabaseBroker):
|
|
1741
1760
|
if exclude_others:
|
1742
1761
|
conditions.append('name = ?')
|
1743
1762
|
params.append(self.path)
|
1744
|
-
if includes is
|
1763
|
+
if includes is None:
|
1764
|
+
if end_marker:
|
1765
|
+
conditions.append('lower < ?')
|
1766
|
+
params.append(end_marker)
|
1767
|
+
if marker:
|
1768
|
+
conditions.append("(upper = '' OR upper > ?)")
|
1769
|
+
params.append(marker)
|
1770
|
+
else:
|
1745
1771
|
conditions.extend(('lower < ?', "(upper = '' OR upper >= ?)"))
|
1746
1772
|
params.extend((includes, includes))
|
1747
1773
|
if conditions:
|
1748
1774
|
condition = ' WHERE ' + ' AND '.join(conditions)
|
1775
|
+
if limit is not None and limit >= 0:
|
1776
|
+
condition += ' LIMIT %d' % limit
|
1749
1777
|
columns = SHARD_RANGE_KEYS[:-2]
|
1750
1778
|
for column in SHARD_RANGE_KEYS[-2:]:
|
1751
1779
|
if column in defaults:
|
@@ -1819,27 +1847,34 @@ class ContainerBroker(DatabaseBroker):
|
|
1819
1847
|
|
1820
1848
|
def get_shard_ranges(self, marker=None, end_marker=None, includes=None,
|
1821
1849
|
reverse=False, include_deleted=False, states=None,
|
1822
|
-
include_own=False,
|
1823
|
-
|
1850
|
+
include_own=False, exclude_others=False,
|
1851
|
+
fill_gaps=False):
|
1824
1852
|
"""
|
1825
1853
|
Returns a list of persisted shard ranges.
|
1826
1854
|
|
1827
1855
|
:param marker: restricts the returned list to shard ranges whose
|
1828
|
-
namespace includes or is greater than the marker value.
|
1856
|
+
namespace includes or is greater than the marker value. If
|
1857
|
+
``reverse=True`` then ``marker`` is treated as ``end_marker``.
|
1858
|
+
``marker`` is ignored if ``includes`` is specified.
|
1829
1859
|
:param end_marker: restricts the returned list to shard ranges whose
|
1830
|
-
namespace includes or is less than the end_marker value.
|
1860
|
+
namespace includes or is less than the end_marker value. If
|
1861
|
+
``reverse=True`` then ``end_marker`` is treated as ``marker``.
|
1862
|
+
``end_marker`` is ignored if ``includes`` is specified.
|
1831
1863
|
:param includes: restricts the returned list to the shard range that
|
1832
1864
|
includes the given value; if ``includes`` is specified then
|
1833
|
-
``marker`` and ``end_marker`` are ignored
|
1865
|
+
``fill_gaps``, ``marker`` and ``end_marker`` are ignored, but other
|
1866
|
+
constraints are applied (e.g. ``exclude_others`` and
|
1867
|
+
``include_deleted``).
|
1834
1868
|
:param reverse: reverse the result order.
|
1835
|
-
:param include_deleted: include items that have the delete marker set
|
1869
|
+
:param include_deleted: include items that have the delete marker set.
|
1836
1870
|
:param states: if specified, restricts the returned list to shard
|
1837
1871
|
ranges that have the given state(s); can be a list of ints or a
|
1838
1872
|
single int.
|
1839
1873
|
:param include_own: boolean that governs whether the row whose name
|
1840
1874
|
matches the broker's path is included in the returned list. If
|
1841
|
-
True, that row is included
|
1842
|
-
|
1875
|
+
True, that row is included unless it is excluded by other
|
1876
|
+
constraints (e.g. ``marker``, ``end_marker``, ``includes``). If
|
1877
|
+
False, that row is not included. Default is False.
|
1843
1878
|
:param exclude_others: boolean that governs whether the rows whose
|
1844
1879
|
names do not match the broker's path are included in the returned
|
1845
1880
|
list. If True, those rows are not included, otherwise they are
|
@@ -1847,9 +1882,14 @@ class ContainerBroker(DatabaseBroker):
|
|
1847
1882
|
:param fill_gaps: if True, insert a modified copy of own shard range to
|
1848
1883
|
fill any gap between the end of any found shard ranges and the
|
1849
1884
|
upper bound of own shard range. Gaps enclosed within the found
|
1850
|
-
shard ranges are not filled.
|
1851
|
-
|
1885
|
+
shard ranges are not filled. ``fill_gaps`` is ignored if
|
1886
|
+
``includes`` is specified.
|
1887
|
+
:return: a list of instances of :class:`swift.common.utils.ShardRange`.
|
1852
1888
|
"""
|
1889
|
+
if includes is None and (marker == Namespace.MAX
|
1890
|
+
or end_marker == Namespace.MIN):
|
1891
|
+
return []
|
1892
|
+
|
1853
1893
|
if reverse:
|
1854
1894
|
marker, end_marker = end_marker, marker
|
1855
1895
|
if marker and end_marker and marker >= end_marker:
|
@@ -1858,17 +1898,13 @@ class ContainerBroker(DatabaseBroker):
|
|
1858
1898
|
shard_ranges = [
|
1859
1899
|
ShardRange(*row)
|
1860
1900
|
for row in self._get_shard_range_rows(
|
1861
|
-
|
1862
|
-
|
1863
|
-
exclude_others=exclude_others)]
|
1864
|
-
|
1901
|
+
marker=marker, end_marker=end_marker, includes=includes,
|
1902
|
+
include_deleted=include_deleted, states=states,
|
1903
|
+
include_own=include_own, exclude_others=exclude_others)]
|
1865
1904
|
shard_ranges.sort(key=ShardRange.sort_key)
|
1866
1905
|
if includes:
|
1867
1906
|
return shard_ranges[:1] if shard_ranges else []
|
1868
1907
|
|
1869
|
-
shard_ranges = filter_shard_ranges(shard_ranges, includes,
|
1870
|
-
marker, end_marker)
|
1871
|
-
|
1872
1908
|
if fill_gaps:
|
1873
1909
|
own_shard_range = self.get_own_shard_range()
|
1874
1910
|
if shard_ranges:
|
@@ -1905,13 +1941,13 @@ class ContainerBroker(DatabaseBroker):
|
|
1905
1941
|
default shard range is returned.
|
1906
1942
|
:return: an instance of :class:`~swift.common.utils.ShardRange`
|
1907
1943
|
"""
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
if
|
1912
|
-
own_shard_range =
|
1944
|
+
rows = self._get_shard_range_rows(
|
1945
|
+
include_own=True, include_deleted=True, exclude_others=True,
|
1946
|
+
limit=1)
|
1947
|
+
if rows:
|
1948
|
+
own_shard_range = ShardRange(*rows[0])
|
1913
1949
|
elif no_default:
|
1914
|
-
|
1950
|
+
own_shard_range = None
|
1915
1951
|
else:
|
1916
1952
|
own_shard_range = ShardRange(
|
1917
1953
|
self.path, Timestamp.now(), ShardRange.MIN, ShardRange.MAX,
|
@@ -1942,9 +1978,41 @@ class ContainerBroker(DatabaseBroker):
|
|
1942
1978
|
|
1943
1979
|
:return: a dict with keys {bytes_used, object_count}
|
1944
1980
|
"""
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1981
|
+
with self.get() as conn:
|
1982
|
+
sql = '''
|
1983
|
+
SELECT COALESCE(SUM(bytes_used), 0),
|
1984
|
+
COALESCE(SUM(object_count), 0)
|
1985
|
+
FROM %s
|
1986
|
+
WHERE state in (%s)
|
1987
|
+
AND deleted = 0
|
1988
|
+
AND name != ?
|
1989
|
+
''' % (SHARD_RANGE_TABLE, ','.join('?' * len(SHARD_STATS_STATES)))
|
1990
|
+
cur = conn.execute(sql, SHARD_STATS_STATES + [self.path])
|
1991
|
+
bytes_used, object_count = cur.fetchone()
|
1992
|
+
return {'bytes_used': bytes_used,
|
1993
|
+
'object_count': object_count}
|
1994
|
+
|
1995
|
+
def has_other_shard_ranges(self):
|
1996
|
+
"""
|
1997
|
+
This function tells if there is any shard range other than the
|
1998
|
+
broker's own shard range, that is not marked as deleted.
|
1999
|
+
|
2000
|
+
:return: A boolean value as described above.
|
2001
|
+
"""
|
2002
|
+
with self.get() as conn:
|
2003
|
+
sql = '''
|
2004
|
+
SELECT 1 FROM %s
|
2005
|
+
WHERE deleted = 0 AND name != ? LIMIT 1
|
2006
|
+
''' % (SHARD_RANGE_TABLE)
|
2007
|
+
try:
|
2008
|
+
data = conn.execute(sql, [self.path])
|
2009
|
+
data.row_factory = None
|
2010
|
+
return True if [row for row in data] else False
|
2011
|
+
except sqlite3.OperationalError as err:
|
2012
|
+
if ('no such table: %s' % SHARD_RANGE_TABLE) in str(err):
|
2013
|
+
return False
|
2014
|
+
else:
|
2015
|
+
raise
|
1948
2016
|
|
1949
2017
|
def get_all_shard_range_data(self):
|
1950
2018
|
"""
|
swift/container/server.py
CHANGED
@@ -860,7 +860,14 @@ class ContainerController(BaseStorageServer):
|
|
860
860
|
@public
|
861
861
|
@timing_stats()
|
862
862
|
def POST(self, req):
|
863
|
-
"""
|
863
|
+
"""
|
864
|
+
Handle HTTP POST request.
|
865
|
+
|
866
|
+
A POST request will update the container's ``put_timestamp``, unless
|
867
|
+
it has an ``X-Backend-No-Timestamp-Update`` header with a truthy value.
|
868
|
+
|
869
|
+
:param req: an instance of :class:`~swift.common.swob.Request`.
|
870
|
+
"""
|
864
871
|
drive, part, account, container = get_container_name_and_placement(req)
|
865
872
|
req_timestamp = valid_timestamp(req)
|
866
873
|
if 'x-container-sync-to' in req.headers:
|
@@ -878,7 +885,9 @@ class ContainerController(BaseStorageServer):
|
|
878
885
|
broker = self._get_container_broker(drive, part, account, container)
|
879
886
|
if broker.is_deleted():
|
880
887
|
return HTTPNotFound(request=req)
|
881
|
-
|
888
|
+
if not config_true_value(
|
889
|
+
req.headers.get('x-backend-no-timestamp-update', False)):
|
890
|
+
broker.update_put_timestamp(req_timestamp.internal)
|
882
891
|
self._update_metadata(req, broker, req_timestamp, 'POST')
|
883
892
|
return HTTPNoContent(request=req)
|
884
893
|
|
swift/container/sharder.py
CHANGED
@@ -38,7 +38,8 @@ from swift.common.swob import str_to_wsgi
|
|
38
38
|
from swift.common.utils import get_logger, config_true_value, \
|
39
39
|
dump_recon_cache, whataremyips, Timestamp, ShardRange, GreenAsyncPile, \
|
40
40
|
config_positive_int_value, quorum_size, parse_override_options, \
|
41
|
-
Everything, config_auto_int_value, ShardRangeList, config_percent_value
|
41
|
+
Everything, config_auto_int_value, ShardRangeList, config_percent_value, \
|
42
|
+
node_to_string
|
42
43
|
from swift.container.backend import ContainerBroker, \
|
43
44
|
RECORD_TYPE_SHARD, UNSHARDED, SHARDING, SHARDED, COLLAPSED, \
|
44
45
|
SHARD_UPDATE_STATES, sift_shard_ranges, SHARD_UPDATE_STAT_STATES
|
@@ -60,7 +61,7 @@ def sharding_enabled(broker):
|
|
60
61
|
# if broker has been marked deleted it will have lost sysmeta, but we still
|
61
62
|
# need to process the broker (for example, to shrink any shard ranges) so
|
62
63
|
# fallback to checking if it has any shard ranges
|
63
|
-
if broker.
|
64
|
+
if broker.has_other_shard_ranges():
|
64
65
|
return True
|
65
66
|
return False
|
66
67
|
|
@@ -895,7 +896,6 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
895
896
|
internal_client_conf_path,
|
896
897
|
'Swift Container Sharder',
|
897
898
|
request_tries,
|
898
|
-
allow_modify_pipeline=False,
|
899
899
|
use_replication_network=True,
|
900
900
|
global_conf={'log_name': '%s-ic' % conf.get(
|
901
901
|
'log_name', self.log_route)})
|
@@ -1079,13 +1079,13 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
1079
1079
|
# container DB, which predicates sharding starting. But s-m-s-r and
|
1080
1080
|
# auto-sharding do set epoch and then merge, so we use it to tell
|
1081
1081
|
# whether sharding has been taking too long or not.
|
1082
|
-
self.warning(
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1082
|
+
self.warning(
|
1083
|
+
broker, 'Cleaving has not completed in %.2f seconds since %s. '
|
1084
|
+
'DB state: %s, own_shard_range state: %s, state count of '
|
1085
|
+
'shard ranges: %s' %
|
1086
|
+
(time.time() - float(own_shard_range.epoch),
|
1087
|
+
own_shard_range.epoch.isoformat, db_state,
|
1088
|
+
own_shard_range.state_text, str(state_count)))
|
1089
1089
|
|
1090
1090
|
def _report_stats(self):
|
1091
1091
|
# report accumulated stats since start of one sharder cycle
|
@@ -1196,13 +1196,13 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
1196
1196
|
headers=headers, contents=body)
|
1197
1197
|
except DirectClientException as err:
|
1198
1198
|
self.warning(broker,
|
1199
|
-
'Failed to put shard ranges to %s
|
1200
|
-
node
|
1199
|
+
'Failed to put shard ranges to %s %s/%s: %s',
|
1200
|
+
node_to_string(node, replication=True),
|
1201
1201
|
quote(account), quote(container), err.http_status)
|
1202
1202
|
except (Exception, Timeout) as err:
|
1203
1203
|
self.exception(broker,
|
1204
|
-
'Failed to put shard ranges to %s
|
1205
|
-
node
|
1204
|
+
'Failed to put shard ranges to %s %s/%s: %s',
|
1205
|
+
node_to_string(node, replication=True),
|
1206
1206
|
quote(account), quote(container), err)
|
1207
1207
|
else:
|
1208
1208
|
return True
|
@@ -2331,9 +2331,13 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
2331
2331
|
return
|
2332
2332
|
|
2333
2333
|
# now look and deal with misplaced objects.
|
2334
|
+
move_start_ts = time.time()
|
2334
2335
|
self._move_misplaced_objects(broker)
|
2336
|
+
self.logger.timing_since(
|
2337
|
+
'sharder.sharding.move_misplaced', move_start_ts)
|
2335
2338
|
|
2336
2339
|
is_leader = node['index'] == 0 and self.auto_shard and not is_deleted
|
2340
|
+
|
2337
2341
|
if state in (UNSHARDED, COLLAPSED):
|
2338
2342
|
if is_leader and broker.is_root_container():
|
2339
2343
|
# bootstrap sharding of root container
|
@@ -2344,15 +2348,18 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
2344
2348
|
|
2345
2349
|
own_shard_range = broker.get_own_shard_range()
|
2346
2350
|
if own_shard_range.state in ShardRange.CLEAVING_STATES:
|
2347
|
-
if broker.
|
2351
|
+
if broker.has_other_shard_ranges():
|
2348
2352
|
# container has been given shard ranges rather than
|
2349
2353
|
# found them e.g. via replication or a shrink event,
|
2350
2354
|
# or manually triggered cleaving.
|
2355
|
+
db_start_ts = time.time()
|
2351
2356
|
if broker.set_sharding_state():
|
2352
2357
|
state = SHARDING
|
2353
2358
|
self.info(broker, 'Kick off container cleaving, '
|
2354
2359
|
'own shard range in state %r',
|
2355
2360
|
own_shard_range.state_text)
|
2361
|
+
self.logger.timing_since(
|
2362
|
+
'sharder.sharding.set_state', db_start_ts)
|
2356
2363
|
elif is_leader:
|
2357
2364
|
if broker.set_sharding_state():
|
2358
2365
|
state = SHARDING
|
@@ -2363,6 +2370,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
2363
2370
|
own_shard_range.state_text)
|
2364
2371
|
|
2365
2372
|
if state == SHARDING:
|
2373
|
+
cleave_start_ts = time.time()
|
2366
2374
|
if is_leader:
|
2367
2375
|
num_found = self._find_shard_ranges(broker)
|
2368
2376
|
else:
|
@@ -2377,6 +2385,8 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
2377
2385
|
|
2378
2386
|
# always try to cleave any pending shard ranges
|
2379
2387
|
cleave_complete = self._cleave(broker)
|
2388
|
+
self.logger.timing_since(
|
2389
|
+
'sharder.sharding.cleave', cleave_start_ts)
|
2380
2390
|
|
2381
2391
|
if cleave_complete:
|
2382
2392
|
if self._complete_sharding(broker):
|
@@ -2384,6 +2394,9 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
2384
2394
|
self._increment_stat('visited', 'completed', statsd=True)
|
2385
2395
|
self.info(broker, 'Completed cleaving, DB set to sharded '
|
2386
2396
|
'state')
|
2397
|
+
self.logger.timing_since(
|
2398
|
+
'sharder.sharding.completed',
|
2399
|
+
float(broker.get_own_shard_range().epoch))
|
2387
2400
|
else:
|
2388
2401
|
self.info(broker, 'Completed cleaving, DB remaining in '
|
2389
2402
|
'sharding state')
|
@@ -2391,6 +2404,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
2391
2404
|
if not broker.is_deleted():
|
2392
2405
|
if state == SHARDED and broker.is_root_container():
|
2393
2406
|
# look for shrink stats
|
2407
|
+
send_start_ts = time.time()
|
2394
2408
|
self._identify_shrinking_candidate(broker, node)
|
2395
2409
|
if is_leader:
|
2396
2410
|
self._find_and_enable_shrinking_candidates(broker)
|
@@ -2400,6 +2414,8 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
2400
2414
|
self._send_shard_ranges(broker, shard_range.account,
|
2401
2415
|
shard_range.container,
|
2402
2416
|
[shard_range])
|
2417
|
+
self.logger.timing_since(
|
2418
|
+
'sharder.sharding.send_sr', send_start_ts)
|
2403
2419
|
|
2404
2420
|
if not broker.is_root_container():
|
2405
2421
|
# Update the root container with this container's shard range
|
@@ -2408,7 +2424,10 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
|
|
2408
2424
|
# sharding a shard, this is when the root will see the new
|
2409
2425
|
# shards move to ACTIVE state and the sharded shard
|
2410
2426
|
# simultaneously become deleted.
|
2427
|
+
update_start_ts = time.time()
|
2411
2428
|
self._update_root_container(broker)
|
2429
|
+
self.logger.timing_since(
|
2430
|
+
'sharder.sharding.update_root', update_start_ts)
|
2412
2431
|
|
2413
2432
|
self.debug(broker,
|
2414
2433
|
'Finished processing, state %s%s',
|