Skip to content

Instantly share code, notes, and snippets.

@marcocitus
Last active April 1, 2018 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcocitus/64c445d73733a773939c968087806da0 to your computer and use it in GitHub Desktop.
Save marcocitus/64c445d73733a773939c968087806da0 to your computer and use it in GitHub Desktop.
Repair all shard placements in shardstate 3
CREATE OR REPLACE FUNCTION public.repair_all()
RETURNS void
LANGUAGE plpgsql
AS $function$
BEGIN
PERFORM
master_copy_shard_placement(shardid, h.nodename, h.nodeport, u.nodename, u.nodeport)
FROM
(SELECT shardid, nodename, nodeport FROM pg_dist_shard_placement WHERE shardstate = 3) u
JOIN
(SELECT DISTINCT (shardid) shardid, nodename, nodeport FROM pg_dist_shard_placement WHERE shardstate = 1) h
USING
(shardid);
END;
$function$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment