Skip to content

Commit

Permalink
chimera: fix rollback of 9.1 to 9.0 db schema
Browse files Browse the repository at this point in the history
Motivation:
Fixes f3286f9

Modification:
fix rollback section of changeset

org/dcache/chimera/changelog/changeset-9.1.xml::34::tigran

Introduce `dcache checksum` command to checksum doesn't change

Result:
restored possibility to rollback namespace db to an earlier schema
version

Acked-by: Dmitry Litvintsev
Target: master, 9.2, 9.1
Require-book: no
Require-notes: yes
(cherry picked from commit 8aa9e6a)
Signed-off-by: Tigran Mkrtchyan <[email protected]>
  • Loading branch information
kofemann authored and mksahakyan committed Nov 7, 2023
1 parent 95fcd5d commit cefea2f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@
<rollback>
<sql>
DROP FUNCTION IF EXISTS f_create_inode95_lazy_wcc(parent bigint, name varchar, id varchar, type integer, mode integer, nlink integer, uid integer, gid int, size bigint, io integer, now timestamp);
DROP FUNCTION IF EXISTS CREATE f_propagate_wcc();
DROP FUNCTION IF EXISTS f_propagate_wcc();
DROP TABLE IF EXISTS t_lazy_wcc;
</sql>
<createProcedure>
CREATE OR REPLACE FUNCTION f_create_inode95(parent bigint, name varchar, id varchar, type integer, mode integer, nlink integer, uid integer, gid int, size bigint, io integer, now timestamp) RETURNS bigint AS $$
DECLARE
newid bigint;
BEGIN
INSERT INTO t_inodes (ipnfsid, itype, imode, iuid, igid, isize, iio, ictime, iatime, imtime, icrtime, igeneration)
INSERT INTO t_inodes (ipnfsid, itype, imode, inlink, iuid, igid, isize, iio, ictime, iatime, imtime, icrtime, igeneration)
VALUES (id,type,mode,nlink,uid,gid,size,io,now,now,now,now,0) RETURNING inumber INTO newid;
INSERT INTO t_dirs (iparent, ichild, iname) VALUES (parent, newid, name) ON CONFLICT ON CONSTRAINT t_dirs_pkey DO NOTHING;
IF NOT FOUND THEN
Expand Down
20 changes: 20 additions & 0 deletions skel/bin/dcache
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ usage()
echo " database listLocks [<cell>@<domain>]..."
echo " database releaseLocks [<cell>@<domain>]..."
echo " database doc <cell>@<domain> <out-dir>"
echo " database checksum <changeid> [<cell>@<domain>]..."
echo " dump heap [--force] <domain> <file>"
echo " dump threads [<domain>...]"
echo " dump zklog [<path>]"
Expand Down Expand Up @@ -914,6 +915,25 @@ case "$1" in
done
;;

checksum)
if [ $# -lt 1 ]; then
usage
fi

id=$1
shift
for domain in $(getProperty dcache.domains); do
for cell in $(getProperty dcache.domain.cells "$domain"); do
if [ $# -eq 0 ] || matchesAny "$cell@$domain" "$@"; then
if hasManagedDatabase "$domain" "$cell"; then
printf -- "-- %s: \n" "$cell@$domain"
liquibase "$domain" "$cell" calculateCheckSum $id
fi
fi
done
done
;;

tag)
if [ $# -lt 1 ]; then
usage
Expand Down

0 comments on commit cefea2f

Please sign in to comment.