Skip to content

Commit d0196f0

Browse files
committed
only retry for splits
1 parent 7f359df commit d0196f0

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

splitio/sync/synchronizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ def sync_all(self):
268268
attempts -= 1
269269
continue
270270

271+
# Only retrying splits, since segments may trigger too many calls.
271272
if not self._synchronize_segments():
272-
attempts -= 1
273-
continue
273+
_LOGGER.warn('Segments failed to synchronize.')
274274

275275
# All is good
276276
return

tests/sync/test_synchronizer.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def sync_segments(*_):
233233
assert counts['splits'] == 1
234234
assert counts['segments'] == 1
235235

236-
def test_sync_all_attempts(self, mocker):
236+
def test_sync_all_split_attempts(self, mocker):
237237
"""Test that 3 attempts are done before failing."""
238238
split_synchronizers = mocker.Mock(spec=SplitSynchronizers)
239239
counts = {'splits': 0, 'segments': 0}
@@ -249,18 +249,20 @@ def sync_splits(*_):
249249
synchronizer.sync_all()
250250
assert counts['splits'] == 3
251251

252-
def test_sync_all_attempts(self, mocker):
253-
"""Test that 3 attempts are done before failing."""
252+
def test_sync_all_segment_attempts(self, mocker):
253+
"""Test that segments don't trigger retries."""
254254
split_synchronizers = mocker.Mock(spec=SplitSynchronizers)
255255
counts = {'splits': 0, 'segments': 0}
256+
256257
def sync_segments(*_):
257258
"""Sync Splits."""
259+
258260
counts['segments'] += 1
259-
raise Exception('sarasa')
261+
return False
260262

261263
split_synchronizers.segment_sync.synchronize_segments.side_effect = sync_segments
262264
split_tasks = mocker.Mock(spec=SplitTasks)
263265
synchronizer = Synchronizer(split_synchronizers, split_tasks)
264266

265267
synchronizer.sync_all()
266-
assert counts['segments'] == 3
268+
assert counts['segments'] == 1

0 commit comments

Comments
 (0)