Surprise: Documentum loses data

I’m not sure whether it is a common practice, but all Documentum projects I have participated in, have the following requirement: every document, created in repository, must have unique human-readable identifier, which business users may refer in their daily activities, extra requirements could be:

  • identifiers are sequential
  • there should no holes in sequence
  • sequence starts from the beginning on every new day/week/month/year

and, depending on the requirements, implementation could be either optimistic:

private int getAnnualNextNumber(ICounter counter)
        throws DfException {
    DfException resultException = null;
    for (int i = 0; i < 10; i++) {
        try {
            synchronized (CounterService.class) {
                int lastNumber = counter.getLastNumber() + 1;
                counter.setLastNumber(lastNumber);
                counter.save();
                return lastNumber;
            }
        } catch (DfException dfe) {
            resultException = dfe;
            // neither fetch nor revert is required because DFC
            // resets object's state in
            // com.documentum.fc.client.DfSysObject#doSave
            // counter.fetch(null);
        }
    }
    throw resultException;
}

or pessimistic:

private int getAnnualNextNumber(ICounter counter)
    throws DfException {
    synchronized (CounterService.class) {
        counter.lock();
        int lastNumber = counter.getLastNumber() + 1;
        counter.setLastNumber(lastNumber);
        counter.save();
        return lastNumber;
    }
}

Interesting thing here is in case of optimistic implementation we observe that our code generates duplicates, from audit perspective it looks like CS does not receive updated value from DFC:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s