Fix test_delayed_replica_failover

This commit is contained in:
Antonio Andelic 2024-09-20 15:31:23 +02:00
parent 9e12b6cb4e
commit 2e715ccf47
3 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include <Client/ConnectionEstablisher.h>
#include <Common/quoteString.h>
#include <Common/ProfileEvents.h>
#include <Common/FailPoint.h>
#include <Core/Settings.h>
namespace ProfileEvents
@ -27,6 +28,11 @@ namespace ErrorCodes
extern const int SOCKET_TIMEOUT;
}
namespace FailPoints
{
extern const char replicated_merge_tree_all_replicas_stale[];
}
ConnectionEstablisher::ConnectionEstablisher(
ConnectionPoolPtr pool_,
const ConnectionTimeouts * timeouts_,
@ -91,7 +97,15 @@ void ConnectionEstablisher::run(ConnectionEstablisher::TryResult & result, std::
const UInt32 delay = table_status_it->second.absolute_delay;
if (delay < max_allowed_delay)
{
result.is_up_to_date = true;
fiu_do_on(FailPoints::replicated_merge_tree_all_replicas_stale,
{
result.delay = 1;
result.is_up_to_date = false;
});
}
else
{
result.is_up_to_date = false;

View File

@ -65,6 +65,7 @@ static struct InitFiu
PAUSEABLE(infinite_sleep) \
PAUSEABLE(stop_moving_part_before_swap_with_active) \
REGULAR(slowdown_index_analysis) \
REGULAR(replicated_merge_tree_all_replicas_stale) \
namespace FailPoints

View File

@ -63,6 +63,9 @@ def create_tables():
def test(started_cluster):
instance_with_dist_table.query(
"SYSTEM DISABLE FAILPOINT replicated_merge_tree_all_replicas_stale"
)
with PartitionManager() as pm:
# Hinder replication between replicas of the same shard, but leave the possibility of distributed connection.
pm.partition_instances(node_1_1, node_1_2, port=9009)
@ -124,6 +127,9 @@ SELECT sum(x) FROM distributed WITH TOTALS SETTINGS
else:
raise Exception("Connection with zookeeper was not lost")
instance_with_dist_table.query(
"SYSTEM ENABLE FAILPOINT replicated_merge_tree_all_replicas_stale"
)
# At this point all replicas are stale, but the query must still go to second replicas which are the least stale ones.
assert (
instance_with_dist_table.query(