[
https://forge.continuent.org/jira/browse/SEQUOIA-975?page=comments#action_14318
]
Cesar Acuna commented on SEQUOIA-975:
-------------------------------------
This was my solution for this problem :
public class SEQUOIAPostgreSQLDialect extends PostgreSQLDialect {
@Override
public String getSequenceNextValString(String sequenceName) {
return "select nextval('" + sequenceName + "') for update";
}
}
> Insert statements fail after 'call Nextval' in PostgreSQL cluster
> -----------------------------------------------------------------
>
> Key: SEQUOIA-975
> URL: https://forge.continuent.org/jira/browse/SEQUOIA-975
> Project: Sequoia
> Type: Bug
> Components: Core
> Versions: Sequoia 2.10.9
> Environment: Windows, Hibernate, PostgreSQL and Spring
> Reporter: Love Singhal
>
>
> I am currently facing this issue and is a blocker for me.
> I have a Spring and Hibernate based Java server which is connected to
> PostgreSQL database. I want to add database clustering to it using sequoia.
> The server uses sequences to generate various Ids. One sequence
> 'hibernate_sequence' is automatically used by the Hibernate framework.
> I installed a sequoia cluster of two databases with two controllers. To
> enable synchronization of sequences, I changed the sql query 'select nextval'
> to '{call nextval.. }' as mentioned in the documents. For hibernate, I
> defined the new SQL dialect which changes the nextVal query string.
> However, I am finding that the database statements that do an insert
> statement along with the 'call nextval' statement in the same transaction
> fail consistently. The error returned in the logs and to the server is:
> > uncategorized SQLException for SQL [insert into category (name,
> > description, prefix, server_path, category_id) values (?, ?, ?, ?, ?)]; SQL
> > state [null]; error code [0]; Batch failed for request 0: insert into
> > category (name, description, prefix, server_path, category_id) values (?,
> > ?, ?, ?, ?)
> > (org.continuent.sequoia.common.exceptions.driver.DriverSQLException:
> > Message of cause: write request 562949953421404 failed:
> Backend ras - BackendWorkerThread for backend 'localhost2' with RAIDb level:1
> failed (ERROR: current transaction is aborted, commands ignored until end of
> transaction block)
> The ras is the name of the virtual database.
> All kinds of insert requests (not necessarily, in the category table) are
> failing when they are called along with the call nextval statement. The call
> nextval statement always succeeds. The error is also same for all kinds of
> inserts. Everytime, backend localhost2 has some problem. I tried to locate
> the cause of the problem in the logs but could not find anything that
> specifies the cause (even after setting up everything to DEBUG log level). I
> cant do a '{call nextval}' in a separate transaction as these calls are
> automatically made by hibernate.
> When I revert back the '{call nextval' statement to 'select nextval', things
> work fine until some primary key gets duplicated (sequences in the two
> databases become unequal). Also, the update calls along with '{call nextval'
> seem to succeed.
> I am now stuck with this issue and could not proceed any further with
> clustering. Please help.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://forge.continuent.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
_______________________________________________
Sequoia mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/sequoia