Skip to content

Commit 01383bc

Browse files
committed
Add regression test for schema deadlock
Regression test for deadlock when performing schema change right after killing a node: scylladb#168
1 parent 7b287a8 commit 01383bc

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
import logging
3+
import unittest
4+
5+
from tests.integration import use_cluster, get_node, local, TestCluster
6+
7+
LOGGER = logging.getLogger(__name__)
8+
9+
10+
def setup_module():
11+
use_cluster('test_concurrent_schema_change_and_node_kill', [3], start=True)
12+
13+
@local
14+
class TestConcurrentSchemaChangeAndNodeKill(unittest.TestCase):
15+
@classmethod
16+
def setup_class(cls):
17+
cls.cluster = TestCluster(max_schema_agreement_wait=120)
18+
cls.session = cls.cluster.connect()
19+
20+
@classmethod
21+
def teardown_class(cls):
22+
cls.cluster.shutdown()
23+
24+
def test_schema_change_after_node_kill(self):
25+
node2 = get_node(2)
26+
self.session.execute(
27+
"DROP KEYSPACE IF EXISTS ks_deadlock;")
28+
self.session.execute(
29+
"CREATE KEYSPACE IF NOT EXISTS ks_deadlock "
30+
"WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2' };")
31+
self.session.set_keyspace('ks_deadlock')
32+
self.session.execute("CREATE TABLE IF NOT EXISTS some_table(k int, c int, v int, PRIMARY KEY (k, v));")
33+
self.session.execute("INSERT INTO some_table (k, c, v) VALUES (1, 2, 3);")
34+
node2.stop(wait=False, gently=False)
35+
self.session.execute("ALTER TABLE some_table ADD v2 int;", timeout=180)
36+
print(self.session.execute("SELECT * FROM some_table WHERE k = 1;").all())

0 commit comments

Comments
 (0)