Skip to content

Commit

Permalink
Revert "enable tablets in kespaces created by node.stress"
Browse files Browse the repository at this point in the history
This reverts commit a3645ac.

There's no need in equipping keyspace creation with any tablets-related
options to make it work. Modern Scylla turns on tablets for keyspace
once the respective cluster feature is enabled

fixes: scylladb#548
  • Loading branch information
xemul authored and fruch committed Jan 17, 2024
1 parent 50cfb26 commit 6209d9d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 79 deletions.
4 changes: 0 additions & 4 deletions ccmlib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,3 @@ def error(self, message):
@staticmethod
def is_docker():
return False

@property
def tablets_enabled(self) -> bool:
return 'tablets' in self._config_options.get('experimental_features', [])
46 changes: 1 addition & 45 deletions ccmlib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import errno
import glob
import itertools
import math
import os
import re
import shutil
Expand All @@ -17,7 +16,6 @@
from datetime import datetime
import locale
from collections import namedtuple
from typing import List, Optional

import yaml

Expand Down Expand Up @@ -1321,14 +1319,7 @@ def stress_process(self, stress_options, **kwargs):
# specify used jmx port if not already set
if not [opt for opt in stress_options if opt.startswith('jmx=')]:
stress_options.extend(['-port', 'jmx=' + self.jmx_port])
if self.cluster.tablets_enabled:
smp = sum([node._smp or 1 for node in self.cluster.nodes.values()])
# default initial tablets: 32 * `sum of SMPs in cluster` coerced to power of 2 (suitable for small number of tables)
initial_tablets = int(math.pow(2, math.ceil(math.log(smp*32, 2))))
self.debug("tablets enabled, adjusting stress options by replication strategy change.")
stress_options = self._set_keyspace_initial_tablets(
stress_options, datacenter=self.data_center, initial_tablets=initial_tablets
)

args = stress + stress_options
stdout_handle = kwargs.pop("stdout", subprocess.PIPE)
stderr_handle = kwargs.pop("stderr", subprocess.PIPE)
Expand All @@ -1346,41 +1337,6 @@ def stress(self, stress_options=None, capture_output=False, **kwargs):
except KeyboardInterrupt:
pass

@staticmethod
def _set_keyspace_initial_tablets(stress_options: List[str], initial_tablets:int = 8,
datacenter: Optional[str] = None, rf: int = 1) -> List[str]:
normalized_stress_options = []
for stress_option in stress_options:
# sometimes users pass schema params in one str, split it
if stress_option.startswith("-schema"):
if " " in stress_option:
normalized_stress_options += stress_option.split()
continue
normalized_stress_options.append(stress_option)
stress_options = normalized_stress_options
datacenter = datacenter or 'datacenter1'
default_replication = f"replication(strategy=NetworkTopologyStrategy,{datacenter}={rf},initial_tablets={initial_tablets})"
try:
idx = stress_options.index('-schema')
replication = stress_options[idx + 1]
if 'replication' in replication:
if 'NetworkTopologyStrategy' in replication:
# if NTP already set, just prepend initial_tablets
replication = re.sub(r'replication\(.+?\)',
lambda m: m.group(0).replace(')', f',initial_tablets={initial_tablets})'), replication)
else:
replication = re.sub(r'replication\(.*factor=(\d+)\)',
f'replication(strategy=NetworkTopologyStrategy,{datacenter}=' + r'\1' + f',initial_tablets={initial_tablets})',
replication)
stress_options[idx + 1] = replication
else:
# no replication provided in -schema, use default
stress_options.insert(idx + 1, default_replication)
except ValueError:
# no -schema provided
stress_options += ['-schema', default_replication]
return stress_options

@staticmethod
def _set_stress_val(key, val, res):
def parse_num(s):
Expand Down
30 changes: 0 additions & 30 deletions tests/test_set_keyspace_initial_tablets.py

This file was deleted.

0 comments on commit 6209d9d

Please sign in to comment.