geosolutions-it/C198-KRIHS

GeoFence raise an exception with priority 0

Opened this issue · 7 comments

When we try to create a new GeoFence rule (with priority 0 or others values already used) we obtain the following error:

image.png

We can create a rule if we use as priority for example the max(priority)+1

@simboss can you suggest me some dev to take a look on it?

etj commented

Priority has the unique constraint: all the rules should be completely ordered.

Anyway the wiki reports 3 types of RUle insertion but, for sake of simplicity of the GUI, I guess the fixedPriority procedure is used:

fixedPriority: a fixed priority number. If a Rule already exists with the same priority value, all existing rules with
priority >= value will have their priority incremented by 1.

In the code I see the shift is not called if a rule with the same priority already exists, so the documented behaviour is not honoured.

@etj it seems to be the behaviour in others GeoServer+GeoFence (embedded) installation. But not here in KRIHS.

From the GeoServer Log:

2020-12-11 17:43:33,062 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 50000, SQLState: HY000
2020-12-11 17:43:33,062 ERROR [org.hibernate.util.JDBCExceptionReporter] - General error: java.lang.ArrayIndexOutOfBoundsException: 512; SQL statement:
update public.gf_rule set priority=priority+? where priority>=? [50000-119]

Probably the H2 database file is corrupted. Read here

@randomorder I think better to use the PostgreSQL database instead of H2.

@randomorder never use H2 in production installations of GeoFence, always PostgreSQL!!!