Patrick had reached out on Skype where he explained that they are facing
these issues as their number of transactions increase. Adding some details
of the conversation along with additional context back to the list

1) Possible Temporary fix: Fineract can be configured to automatically
retry such transactions

The table `tenant_server_connections` under the schema
`mifosplatform-tenants` has two columns `deadlock max_retries` and
`deadlock_max_retry_interval` which can be configured to control the number
of times and intervals at which such failed transactions can be retried.

These settings control the retrying of transactions throwing the following
exceptions
-> `org.springframework.dao.CannotAcquireLockException`
-> `org.springframework.orm.ObjectOptimisticLockingFailureException`.

They worked earlier (in the original MifosX distributions) when Hibernate
was the ORM used and Hibernate's exceptions like StaleObjectStateException,
StaleStateException and OptimisticEntityLockException were converted to
org.springframework.orm.ObjectOptimisticLockingFailureException. I am not
sure if they work post the change to using OpenJPA on Fineract (this is
unclear in the log snippet shared)

2) Possible Temporary fixes to improve performance:

Patrick seemed to be having an average response time of 3 sec.  They seem
to have sufficient hardware resources on AWS dedicated to the application
server, so areas, where we could optimize, would include

-> Consider using either MySQL or MariaDB driver which should perform
better than the drizzle driver used by Fineract.
-> Ensure MySQL is configured correctly for the available hardware. While
tools like https://github.com/major/MySQLTuner-perl would help identify
basic issues, consider moving to a managed enterprise MySQL compliant
database like https://aws.amazon.com/rds/aurora/


3) Permanent fix:
Deposit accounts on Fineract were originally designed for use as
Micro-finance savings accounts. After every deposit or withdrawal on
Fineract, interest calculation is carried out on the fly, starting from the
creation of the account. This approach wouldn't scale for a use case like a
mobile wallet for merchants etc. The only solution would be to make a code
level changes to decouple interest calculation (for total interest earned)
from deposits/withdrawals.

Regards,
Vishwas


On Tue, Apr 23, 2019 at 7:49 AM Patrick Asare-Frimpong <patr...@hubtel.com>
wrote:

> Hi team,
>
>
>
> I am getting the error below when I try withdrawing multiple times from an
> account
>
>
>
> [http-bio-8443-exec-206] ERROR o.s.boot.context.web.ErrorPageFilter -
> Forwarding to error page from request
> [/api/v1/savingsaccounts/11673/transactions] due to exception [Optimistic
> locking errors were detected when flushing to the data store.  The
> following objects may have been concurrently modified in another
> transaction:
> [org.apache.fineract.portfolio.savings.domain.SavingsAccount-11673]]
> org.apache.openjpa.persistence.OptimisticLockException: Optimistic locking
> errors were detected when flushing to the data store.  The following
> objects may have been concurrently modified in another transaction:
> [org.apache.fineract.portfolio.savings.domain.SavingsAccount-11673]
>     at
> org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2357)
> ~[openjpa-all-2.4.1.jar:2.4.1]
>     at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2205)
> ~[openjpa-all-2.4.1.jar:2.4.1]
>     at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2103)
> ~[openjpa-all-2.4.1.jar:2.4.1]
>     at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1874)
> ~[openjpa-all-2.4.1.jar:2.4.1]
>     at
> org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:599)
> ~[openjpa-all-2.4.1.jar:2.4.1]
>     at
> org.apache.openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:686)
> ~[openjpa-all-2.4.1.jar:2.4.1]
>     at
> org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1692)
> ~[openjpa-all-2.4.1.jar:2.4.1]
>     at
> org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1624)
> ~[openjpa-all-2.4.1.jar:2.4.1]
>     at
> org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom.pcGetid(AbstractPersistableCustom.java)
> ~[classes/:na]
>     at
> org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom.getId(AbstractPersistableCustom.java:45)
> ~[classes/:na]
>     at
> org.apache.fineract.portfolio.savings.domain.SavingsAccountDomainServiceJpa.saveTransactionToGenerateTransactionId(SavingsAccountDomainServiceJpa.java:2
>
>
>
>
>
> Please help.
>
>
>
> Patrick
>
>
> --
> *Patrick Asare-Frimpong*
> Senior Product Manager
> [image: Hubtel] <https://www.hubtel.com/>
> T: (+233) 302 256 859
> M:+233 208 800 414
> www.hubtel.com
> [image: Facebook] <https://web.facebook.com/hubtelghana/> [image: Twitter]
> <https://twitter.com/HubtelGhana>
> <https://hubtel.com/mall/deal/easter-deals/>
>

Reply via email to