cancel
Showing results for 
Search instead for 
Did you mean: 

Dead-lock detected during TagService.tag operation

Arnault_
Confirmed Champ
Confirmed Champ

Bonjour

contexte: 5.8 + HF21 - Windows - DtB:H2 - Installation locale avec un seul utilisateur

J'ai créé une opération SetDocumentTag implémentée ainsi:

 public void run(DocumentModel input) throws Exception {
    TagService service = Framework.getLocalService(TagService.class);
    String docId = input.getId();
    log.error("SetDocumentTag> docId=" + docId + " tag=" + label + " username=" + username);

-> service.tag(session, docId, label, username); session.save(); }

De temps en temps j'ai l'erreur suivante dans l'appel service.tag:

Caused by: org.nuxeo.ecm.core.api.ConcurrentUpdateDocumentException: org.nuxeo.ecm.core.storage.ConcurrentUpdateStorageE
xception: org.h2.jdbc.JdbcBatchUpdateException: Deadlock detected. The current transaction was rolled back. Details:
Session #7 (user: SA) is waiting to lock PUBLIC.HIERARCHY while locking PUBLIC.CONTENT (exclusive), PUBLIC.FULLTEXT (exc
lusive).
Session #5 (user: SA) is waiting to lock PUBLIC.FULLTEXT while locking , PUBLIC.HIERARCHY (exclusive), PUBLIC.MISC (excl
usive), PUBLIC.RELATION (exclusive).; SQL statement:
INSERT INTO "FULLTEXT" ("ID", "JOBID", "SIMPLETEXT", "BINARYTEXT", "SIMPLETEXT_TITLE", "BINARYTEXT_TITLE", "SIMPLETEXT_D
ESCRIPTION", "BINARYTEXT_DESCRIPTION") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [40001-114]
        at org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession.save(SQLSession.java:159)
        at org.nuxeo.ecm.core.api.AbstractSession.save(AbstractSession.java:1908)
        ... 100 more
Caused by: org.nuxeo.ecm.core.storage.ConcurrentUpdateStorageException: org.h2.jdbc.JdbcBatchUpdateException: Deadlock d
etected. The current transaction was rolled back. Details:
Session #7 (user: SA) is waiting to lock PUBLIC.HIERARCHY while locking PUBLIC.CONTENT (exclusive), PUBLIC.FULLTEXT (exc
lusive).
Session #5 (user: SA) is waiting to lock PUBLIC.FULLTEXT while locking , PUBLIC.HIERARCHY (exclusive), PUBLIC.MISC (excl
usive), PUBLIC.RELATION (exclusive).; SQL statement:
INSERT INTO "FULLTEXT" ("ID", "JOBID", "SIMPLETEXT", "BINARYTEXT", "SIMPLETEXT_TITLE", "BINARYTEXT_TITLE", "SIMPLETEXT_D
ESCRIPTION", "BINARYTEXT_DESCRIPTION") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [40001-114]
        at org.nuxeo.ecm.core.storage.sql.jdbc.JDBCConnection.checkConcurrentUpdate(JDBCConnection.java:323)
        at org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper.insertSimpleRows(JDBCRowMapper.java:605)
        at org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper.writeCreates(JDBCRowMapper.java:502)
        at org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper.write(JDBCRowMapper.java:472)
        at org.nuxeo.ecm.core.storage.sql.SoftRefCachingRowMapper.write(SoftRefCachingRowMapper.java:427)
        at org.nuxeo.ecm.core.storage.sql.SessionImpl.flush(SessionImpl.java:391)
        at org.nuxeo.ecm.core.storage.sql.SessionImpl.flushAndScheduleWork(SessionImpl.java:365)
        at org.nuxeo.ecm.core.storage.sql.SessionImpl.save(SessionImpl.java:344)
        at org.nuxeo.ecm.core.storage.sql.ra.ConnectionImpl.save(ConnectionImpl.java:184)
        at org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession.save(SQLSession.java:157)
        ... 101 more
Caused by: org.h2.jdbc.JdbcBatchUpdateException: Deadlock detected. The current transaction was rolled back. Details:
Session #7 (user: SA) is waiting to lock PUBLIC.HIERARCHY while locking PUBLIC.CONTENT (exclusive), PUBLIC.FULLTEXT (exc
lusive).
Session #5 (user: SA) is waiting to lock PUBLIC.FULLTEXT while locking , PUBLIC.HIERARCHY (exclusive), PUBLIC.MISC (excl
usive), PUBLIC.RELATION (exclusive).; SQL statement:
INSERT INTO "FULLTEXT" ("ID", "JOBID", "SIMPLETEXT", "BINARYTEXT", "SIMPLETEXT_TITLE", "BINARYTEXT_TITLE", "SIMPLETEXT_D
ESCRIPTION", "BINARYTEXT_DESCRIPTION") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [40001-114]
        at org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1067)
        at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
        at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
        at org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper.insertSimpleRows(JDBCRowMapper.java:590)
        ... 109 more
Caused by: org.h2.jdbc.JdbcSQLException: Deadlock detected. The current transaction was rolled back. Details:
Session #7 (user: SA) is waiting to lock PUBLIC.HIERARCHY while locking PUBLIC.CONTENT (exclusive), PUBLIC.FULLTEXT (exc
lusive).
Session #5 (user: SA) is waiting to lock PUBLIC.FULLTEXT while locking , PUBLIC.HIERARCHY (exclusive), PUBLIC.MISC (excl
usive), PUBLIC.RELATION (exclusive).; SQL statement:
INSERT INTO "FULLTEXT" ("ID", "JOBID", "SIMPLETEXT", "BINARYTEXT", "SIMPLETEXT_TITLE", "BINARYTEXT_TITLE", "SIMPLETEXT_D
ESCRIPTION", "BINARYTEXT_DESCRIPTION") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [40001-114]
        at org.h2.message.Message.getSQLException(Message.java:105)
        at org.h2.message.Message.getSQLException(Message.java:116)
        at org.h2.message.Message.getSQLException(Message.java:75)
        at org.h2.table.TableData.doLock(TableData.java:426)
        at org.h2.table.TableData.lock(TableData.java:373)
        at org.h2.command.dml.Insert.update(Insert.java:100)
        at org.h2.command.CommandContainer.update(CommandContainer.java:72)
        at org.h2.command.Command.executeUpdate(Command.java:208)
        at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:139)
        at org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1050)
        ... 112 more

Comment protéger cet appel contre les transactions non terminées?

Il semble que des événements ne sont pas encore traités au moment de l'appel au TagService ...

Merci de votre aide

Christian

4 REPLIES 4

Florent_Guillau
World-Class Innovator
World-Class Innovator

La base embedded h2 gère très mal la concurrence et n'est donc pas adaptée à quelque sorte de production que ce soit. Nous vous conseillons d'utiliser PostgreSQL par exemple.

Bonjour

...

Pouvez-vous mettre à jour la question initiale avec un lien (pastebin) sur le log d'erreur ?