mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
chore: relax repltakeover constraints to only exclude write commands (#2873)
* relax repltakeover constraints
This commit is contained in:
parent
dd437693f6
commit
1bcbb41ec3
3 changed files with 42 additions and 2 deletions
2
helio
2
helio
|
@ -1 +1 @@
|
|||
Subproject commit f76c73fc6ca8cf1ada04edbb7e64a2465aa0f5b1
|
||||
Subproject commit d819bf4f1bc61e72d9fbe0c37b2ce40354d9689d
|
|
@ -1022,7 +1022,7 @@ std::optional<ErrorReply> Service::VerifyCommandState(const CommandId* cid, CmdA
|
|||
allowed_by_state = false;
|
||||
break;
|
||||
case GlobalState::TAKEN_OVER:
|
||||
allowed_by_state = cid->name() == "REPLCONF" || cid->name() == "SAVE";
|
||||
allowed_by_state = !cid->IsWriteOnly();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -1265,6 +1265,46 @@ async def test_take_over_seeder(
|
|||
await disconnect_clients(c_master, c_replica)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("master_threads, replica_threads", [[4, 4]])
|
||||
@pytest.mark.asyncio
|
||||
async def test_take_over_read_commands(df_local_factory, master_threads, replica_threads):
|
||||
master = df_local_factory.create(
|
||||
proactor_threads=master_threads,
|
||||
logtostderr=True,
|
||||
)
|
||||
replica = df_local_factory.create(proactor_threads=replica_threads)
|
||||
df_local_factory.start_all([master, replica])
|
||||
|
||||
c_master = master.client()
|
||||
await c_master.execute_command("SET foo bar")
|
||||
|
||||
c_replica = replica.client()
|
||||
await c_replica.execute_command(f"REPLICAOF localhost {master.port}")
|
||||
await wait_available_async(c_replica)
|
||||
|
||||
async def prompt():
|
||||
client = replica.client()
|
||||
for i in range(50):
|
||||
# TODO remove try block when we no longer shut down master after take over
|
||||
try:
|
||||
res = await c_master.execute_command("GET foo")
|
||||
assert res == "bar"
|
||||
res = await c_master.execute_command("CONFIG SET aclfile myfile")
|
||||
assert res == "OK"
|
||||
except:
|
||||
pass
|
||||
res = await client.execute_command("GET foo")
|
||||
assert res == "bar"
|
||||
|
||||
promt_task = asyncio.create_task(prompt())
|
||||
await c_replica.execute_command(f"REPLTAKEOVER 5")
|
||||
|
||||
assert await c_replica.execute_command("role") == ["master", []]
|
||||
await promt_task
|
||||
|
||||
await disconnect_clients(c_master, c_replica)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_take_over_timeout(df_local_factory, df_seeder_factory):
|
||||
master = df_local_factory.create(proactor_threads=2, logtostderr=True)
|
||||
|
|
Loading…
Reference in a new issue