I am trying to use the JPA ticket registry in 5.0.1 with Postgres. I can't find any DDL to create the schema so I am letting hibernate create the tables.
In this document
https://apereo.github.io/cas/5.0.x/installation/JPA-Ticket-Registry.html they describe four options for ddlAuto:
validate - validate the schema, but make no changes to the database.
update - update the schema.
create - create the schema, destroying previous data.
create-drop - drop the schema at the end of the session.
If I want to have multiple CAS servers pointing at the same set of tables in the same DB, it doesn't seem like create or create-drop would make sense because they both appear to drop the tables on start-up. The OID of the table changes with the create option on startup so i assume it is re-creating the table.
I would like to use "validate" but after letting the tables be created using the "create" option the validate options fails with an error like:
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-valid
ation: wrong column type encountered in column [lockVer] in table [locks]; found
[int4 (Types#INTEGER)], but expecting [integer default 0 (Types#BIGINT)]
The DDL for the table extracted by pgAdmin shows the column is: "lockVer integer NOT NULL DEFAULT 0" which seems to be what it is expecting.
I can start up CAS with ddlAuto set to "update" but when I login I get an an error:
<ERROR: cannot execute SELECT FOR UPDATE in a read-only transaction>
2016-12-15 09:52:16,249 ERROR [org.apereo.cas.ticket.registry.JpaTicketRegistry]
- <Error getting ticket TGT-**********************************************3osVS
fZwtw-XYZXYZXYZV from registry.>
If I set jpaLockingTgtEnabled to false then I can login but it seems like locking should work in postgres. It appears that DefaultTicketRegistrySupport is @Transactional readonly=true and the getAuthenticatedPrincipalFrom method starts a read-only transaction which eventually fails when hibernate tries to lock row with "for update" clause. Is there another TicketRegistrySupport bean I should be using?
A possibly related issue, I am seeing the DefaultTicketRegistry bean being created from CasCoreTicketsConfiguration despite the bean being @ConditionalOnMissingBean(name = "ticketRegistry"). The jpaTicketRegistry bean which appears to be aliased to ticketRegistry is definitely being used so I am not sure why the DefaultTicketRegistry bean is being created.
To summarize:
- JPA ticket registry seems to be working but the ddlAuto validate doesn't seem to work (and create/create-drop seem no better than in-memory if they are lost on restart)
- jpa locking is not working for me
- I don't know why the DefaultTicketRegistry bean is being created.