Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/release-notes/5345-ejb-timers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Reset the EJB timer database back to default:
```
<payara install path>/asadmin set configs.config.server-config.ejb-container.ejb-timer-service.timer-datasource=jdbc/__TimerPool
```
13 changes: 2 additions & 11 deletions doc/sphinx-guides/source/_static/util/clear_timer.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/sh

# EBJ timers sometimes cause problems; utility to clear generated directories and database rows
# EBJ timers sometimes cause problems; utility to clear generated directories

# assumes this script is being run as root, and that the postgres user had passwordless
# access to the database (local sockets, or appropriate environmental variables).
# assumes this script is being run as root

# will restart Payara if it's stopped; comment out the `start-domain` command at the end
# if you'd like to avoid that.
Expand All @@ -14,19 +13,11 @@ PAYARA_DIR=/usr/local/payara5
# directory within Payara (defaults)
DV_DIR=${PAYARA_DIR}/glassfish/domains/domain1

# name of dataverse database
DV_DB=dvndb

# OS user for the database
DB_USER=postgres

# stop the domain (generates a warning if app server is stopped)
${PAYARA_DIR}/bin/asadmin stop-domain

rm -rf ${PAYARA_DIR}/${DV_DIR}/generated/
rm -rf ${PAYARA_DIR}/${DV_DIR}/osgi-cache/felix

sudo -u ${DB_USER} psql ${DV_DB} -c 'delete from "EJB__TIMER__TBL"';

# restart the domain (also generates a warning if app server is stopped)
${PAYARA_DIR}/bin/asadmin start-domain
6 changes: 2 additions & 4 deletions doc/sphinx-guides/source/admin/timers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ The following JVM option instructs the application to act as the dedicated timer

``-Ddataverse.timerServer=true``

**IMPORTANT:** Note that this option is automatically set by the Dataverse installer script. That means that when **configuring a multi-server cluster**, it will be the responsibility of the installer to remove the option from the :fixedwidthplain:`domain.xml` of every node except the one intended to be the timer server. We also recommend that the following entry in the :fixedwidthplain:`domain.xml`: ``<ejb-timer-service timer-datasource="jdbc/VDCNetDS">`` is changed back to ``<ejb-timer-service>`` on all the non-timer server nodes. Similarly, this option is automatically set by the installer script. Changing it back to the default setting on a server that doesn't need to run the timer will prevent a potential race condition, where multiple servers try to get a lock on the timer database.

**Note** that for the timer to work, the version of the PostgreSQL JDBC driver your instance is using must match the version of your PostgreSQL database. See the :ref:`timer-not-working` section of Troubleshooting in the Admin Guide.
**IMPORTANT:** Note that this option is automatically set by the Dataverse installer script. That means that when **configuring a multi-server cluster**, it will be the responsibility of the installer to remove the option from the :fixedwidthplain:`domain.xml` of every node except the one intended to be the timer server.

Harvesting Timers
-----------------
Expand All @@ -44,7 +42,7 @@ This timer runs a daily job that tries to export all the local, published datase

This daily job will also update all the harvestable OAI sets configured on your server, adding new and/or newly published datasets or marking deaccessioned datasets as "deleted" in the corresponding sets as needed.

This job is automatically scheduled to run at 2AM local time every night. If really necessary, it is possible (for an advanced user) to change that time by directly editing the EJB timer application table in the database.
This job is automatically scheduled to run at 2AM local time every night.

.. _saved-search-timer:

Expand Down
14 changes: 6 additions & 8 deletions doc/sphinx-guides/source/admin/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,12 @@ We don't know what's causing this issue, but here's a known workaround:

- Stop Payara;

- Remove the ``generated`` and ``osgi-cache`` directories;

- Delete all the rows from the ``EJB__TIMER__TBL`` table in the database;
- Remove the ``generated`` and ``osgi-cache`` directories;

- Start Payara

The shell script below performs the steps above.
Note that it may or may not work on your system, so it is provided as an example only, downloadable :download:`here </_static/util/clear_timer.sh>`. Aside from the configuration values that need to be changed to reflect your environment (the Payara directory, name of the database, etc.) the script relies on the database being configured in a certain way for access. (See the comments in the script for more information)
Note that it may or may not work on your system, so it is provided as an example only, downloadable :download:`here </_static/util/clear_timer.sh>`. The configuration values might need to be changed to reflect your environment (the Payara directory). See the comments in the script for more information.

.. literalinclude:: ../_static/util/clear_timer.sh

Expand All @@ -114,7 +112,7 @@ Note that it may or may not work on your system, so it is provided as an example
Timer Not Working
-----------------

Dataverse relies on EJB timers to perform scheduled tasks: harvesting from remote servers, updating the local OAI sets and running metadata exports. (See :doc:`timers` for details.) If these scheduled jobs are not running on your server, this may be the result of the incompatibility between the version of PostgreSQL database you are using, and PostgreSQL JDBC driver in use by your instance of Payara. The symptoms:
Dataverse relies on EJB timers to perform scheduled tasks: harvesting from remote servers, updating the local OAI sets and running metadata exports. (See :doc:`timers` for details.) If these scheduled jobs are not running on your server, you might experience the following symptoms:

If you are seeing the following in your server.log...

Expand All @@ -127,9 +125,9 @@ followed by an Exception stack trace with these lines in it:
:fixedwidthplain:`Exception Description: Could not deserialize object from byte array` ...


... it most likely means that it is the JDBC driver incompatibility that's preventing the timer from working correctly.
Make sure you install the correct version of the driver. For example, if you are running the version 9.3 of PostgreSQL, make sure you have the driver postgresql-9.3-1104.jdbc4.jar in your :fixedwidthplain:`<PAYARA FOLDER>/glassfish/lib` directory. Go `here <https://jdbc.postgresql.org/download.html>`_
to download the correct version of the driver. If you have an older driver in glassfish/lib, make sure to remove it, replace it with the new version and restart Payara. (You may need to remove the entire contents of :fixedwidthplain:`<PAYARA FOLDER>/glassfish/domains/domain1/generated` before you start Payara).
... you should reach out by opening an issue. In the good old days of running Dataverse 4 running on Glassfish 4, this
was a hint for an unsupported JDBC driver. In Dataverse 5 this would be a new regression and its cause would need to be
investigated.


Constraint Violations Issues
Expand Down
3 changes: 1 addition & 2 deletions doc/sphinx-guides/source/installation/installation-main.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ Fresh Reinstall
Early on when you're installing Dataverse, you may think, "I just want to blow away what I've installed and start over." That's fine. You don't have to uninstall the various components like Payara, PostgreSQL and Solr, but you should be conscious of how to clear out their data. For Payara, a common helpful process is to:

- Stop Payara;
- Remove the ``generated`` and ``osgi-cache`` directories;
- Delete all the rows from the ``EJB__TIMER__TBL`` table in the database;
- Remove the ``generated`` and ``osgi-cache`` directories;
- Start Payara

Drop database
Expand Down
5 changes: 0 additions & 5 deletions scripts/installer/as-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ function final_setup(){
# Create data sources
./asadmin $ASADMIN_OPTS create-jdbc-resource --connectionpoolid dvnDbPool jdbc/VDCNetDS

###
# Set up the data source for the timers

./asadmin $ASADMIN_OPTS set configs.config.server-config.ejb-container.ejb-timer-service.timer-datasource=jdbc/VDCNetDS

./asadmin $ASADMIN_OPTS create-jvm-options "\-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"

###
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public SavedSearch save(SavedSearch savedSearch) {
}


@Schedule(dayOfWeek="0", hour="0",minute="30")
@Schedule(dayOfWeek="0", hour="0", minute="30", persistent = false)
public void makeLinksForAllSavedSearchesTimer() {
if (systemConfig.isTimerServer()) {
logger.info("Linking saved searches");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

import edu.harvard.iq.dataverse.DatasetServiceBean;
import edu.harvard.iq.dataverse.Dataverse;
import edu.harvard.iq.dataverse.DataverseServiceBean;
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.authorization.providers.builtin.BuiltinUser;
import edu.harvard.iq.dataverse.authorization.providers.builtin.BuiltinUserServiceBean;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.engine.command.DataverseRequest;
import edu.harvard.iq.dataverse.harvest.client.HarvestingClient;
Expand All @@ -33,13 +30,11 @@
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerConfig;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.http.HttpServletRequest;


Expand All @@ -56,16 +51,14 @@
@Singleton
@Startup
public class DataverseTimerServiceBean implements Serializable {

private static final Logger logger = Logger.getLogger("edu.harvard.iq.dataverse.timer.DataverseTimerServiceBean");

@Resource
javax.ejb.TimerService timerService;
@PersistenceContext(unitName = "VDCNet-ejbPU")
private EntityManager em;
private static final Logger logger = Logger.getLogger("edu.harvard.iq.dataverse.timer.DataverseTimerServiceBean");
@EJB
HarvesterServiceBean harvesterService;
@EJB
DataverseServiceBean dataverseService;
@EJB
HarvestingClientServiceBean harvestingClientService;
@EJB
AuthenticationServiceBean authSvc;
Expand Down Expand Up @@ -105,7 +98,7 @@ public void createTimer(Date initialExpiration, long intervalDuration, Serializa
} catch (UnknownHostException ex) {
Logger.getLogger(DataverseTimerServiceBean.class.getName()).log(Level.SEVERE, null, ex);
}
timerService.createTimer(initialExpiration, intervalDuration, info);
timerService.createIntervalTimer(initialExpiration, intervalDuration, new TimerConfig(info, false));
}

/**
Expand Down