Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Oct 2, 2023
2 parents 425fa22 + a7b4fd0 commit 0397054
Show file tree
Hide file tree
Showing 28 changed files with 140 additions and 76 deletions.
27 changes: 27 additions & 0 deletions config/sql/native/postgres-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,33 @@ call apply_change(24, $aa$
ALTER TABLE m_connector ADD displayNameNorm TEXT;
$aa$);


call apply_change(25, $aa$
CREATE OR REPLACE PROCEDURE m_refresh_org_closure(force boolean = false)
LANGUAGE plpgsql
AS $$
DECLARE
flag_val text;
BEGIN
-- We use advisory session lock only for the check + refresh, then release it immediately.
-- This can still dead-lock two transactions in a single thread on the select/delete combo,
-- (I mean, who would do that?!) but works fine for parallel transactions.
PERFORM pg_advisory_lock(47);
BEGIN
SELECT value INTO flag_val FROM m_global_metadata WHERE name = 'orgClosureRefreshNeeded';
IF flag_val = 'true' OR force THEN
REFRESH MATERIALIZED VIEW m_org_closure;
DELETE FROM m_global_metadata WHERE name = 'orgClosureRefreshNeeded';
END IF;
PERFORM pg_advisory_unlock(47);
EXCEPTION WHEN OTHERS THEN
-- Whatever happens we definitely want to release the lock.
PERFORM pg_advisory_unlock(47);
RAISE;
END;
END;
$$;
$aa$);
---
-- WRITE CHANGES ABOVE ^^
-- IMPORTANT: update apply_change number at the end of postgres-new.sql
Expand Down
40 changes: 19 additions & 21 deletions config/sql/native/postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -897,26 +897,24 @@ AS $$
DECLARE
flag_val text;
BEGIN
SELECT value INTO flag_val FROM m_global_metadata WHERE name = 'orgClosureRefreshNeeded';
IF flag_val = 'true' OR force THEN
-- We use advisory session lock only for the check + refresh, then release it immediately.
-- This can still dead-lock two transactions in a single thread on the select/delete combo,
-- (I mean, who would do that?!) but works fine for parallel transactions.
PERFORM pg_advisory_lock(47);
BEGIN
SELECT value INTO flag_val FROM m_global_metadata WHERE name = 'orgClosureRefreshNeeded';
IF flag_val = 'true' OR force THEN
REFRESH MATERIALIZED VIEW m_org_closure;
DELETE FROM m_global_metadata WHERE name = 'orgClosureRefreshNeeded';
END IF;
PERFORM pg_advisory_unlock(47);
EXCEPTION WHEN OTHERS THEN
-- Whatever happens we definitely want to release the lock.
PERFORM pg_advisory_unlock(47);
RAISE;
END;
END IF;
END; $$;
-- We use advisory session lock only for the check + refresh, then release it immediately.
-- This can still dead-lock two transactions in a single thread on the select/delete combo,
-- (I mean, who would do that?!) but works fine for parallel transactions.
PERFORM pg_advisory_lock(47);
BEGIN
SELECT value INTO flag_val FROM m_global_metadata WHERE name = 'orgClosureRefreshNeeded';
IF flag_val = 'true' OR force THEN
REFRESH MATERIALIZED VIEW m_org_closure;
DELETE FROM m_global_metadata WHERE name = 'orgClosureRefreshNeeded';
END IF;
PERFORM pg_advisory_unlock(47);
EXCEPTION WHEN OTHERS THEN
-- Whatever happens we definitely want to release the lock.
PERFORM pg_advisory_unlock(47);
RAISE;
END;
END;
$$;
-- endregion

-- region OTHER object tables
Expand Down Expand Up @@ -2220,4 +2218,4 @@ END $$;
-- This is important to avoid applying any change more than once.
-- Also update SqaleUtils.CURRENT_SCHEMA_CHANGE_NUMBER
-- repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleUtils.java
call apply_change(24, $$ SELECT 1 $$, true);
call apply_change(25, $$ SELECT 1 $$, true);
44 changes: 41 additions & 3 deletions dist/src/main/bin/midpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,37 @@ ENV_MAP_PREFIX="MP_SET_"
ENV_UNMAP_PREFIX="MP_UNSET_"

######################

# Handling SIGnals
######################
#
# Without this definition the signal received by bash (script) is silently
# ignored - not passed to child processes.
#
######################
_sigterm() {
echo " :SIGNAL PROCESSING: Receiving SIGTERM signal! Passing to the midPoint instance." >&2
if [ -s "${PID_FILE}" ]
then
kill -TERM $(cat "${PID_FILE}") 2>/dev/null
else
echo "Unfortunatelly the PID file is empty..." >&2
fi
}

trap _sigterm SIGTERM

_sigkill() {
echo " : SIGNAL PROCESSING: Receiving SIGKILL signal! Passing to the midPoint instance." >&2
if [ -s "${PID_FILE}" ]
then
kill -KILL $(cat "${PID_FILE}") 2>/dev/null
else
echo "Unfortunatelly the PID file is empty..." >&2
fi
}

trap _sigkill SIGKILL
######################
set -eu

if [[ -z ${1:-} ]]; then
Expand Down Expand Up @@ -426,14 +456,22 @@ if [[ "$1" == "container" ]]; then
if [ "${1:-}" = "" ]; then
eval "\"${_RUNJAVA}\"" \
${JAVA_OPTS} \
-jar "\"${BASE_DIR}/lib/midpoint.jar\"" 2>&1
-jar "\"${BASE_DIR}/lib/midpoint.jar\"" "&" 2>&1
else
eval "\"${_RUNJAVA}\"" \
${JAVA_OPTS} \
-jar "\"${BASE_DIR}/lib/midpoint.jar\"" \
"$@" 2>&1
"$@" "&" 2>&1
fi

if [[ -n "${PID_FILE}" ]]; then
echo $! >"${PID_FILE}"
wait $(cat ${PID_FILE})
else
wait $!
fi

echo "The midPoint process has been terminated..." >&2
fi
# ----- Execute The Requested Command -----------------------------------------

Expand Down
2 changes: 0 additions & 2 deletions infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@

<modules>
<module>schema</module>
<!-- FIXME: Enable after migration to newer jaxb?
<module>schema-pure-jaxb</module>
-->
<module>common</module>
<module>test-util</module>
</modules>
Expand Down
11 changes: 7 additions & 4 deletions infra/schema-pure-jaxb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<version>3.1.0</version>
<executions>
<execution>
<id>xjc</id>
Expand Down Expand Up @@ -112,6 +112,7 @@
<artifactId>xsom</artifactId>
<version>20190730e</version>
</dependency>
<!--
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
Expand All @@ -120,11 +121,13 @@
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
-->
<!-- Latest version, only used here, no security risk (as of 4.6). -->
<version>2.7.3</version>
<!-- <version>2.7.3</version>
</dependency>
-->
<!-- Added after MID-7937, fix based on https://stackoverflow.com/a/71979169/658826 -->
<dependency>
<!--dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${glassfish-jaxb.version}</version>
Expand All @@ -133,7 +136,7 @@
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${glassfish-jaxb.version}</version>
</dependency>
</dependency-->
</dependencies>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:import namespace="http://prism.evolveum.com/xml/ns/public/annotation-3"/>
<xsd:import namespace="http://prism.evolveum.com/xml/ns/public/types-3"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:mr="http://prism.evolveum.com/xml/ns/public/matching-rule-3"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting/extension-3"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
jaxb:version="3.0">

<xsd:annotation>
<xsd:documentation>
Expand Down

0 comments on commit 0397054

Please sign in to comment.