Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bug) Running Balances do not work in Production #1273

Closed
jniles opened this issue Feb 27, 2017 · 0 comments
Closed

(bug) Running Balances do not work in Production #1273

jniles opened this issue Feb 27, 2017 · 0 comments
Assignees
Labels

Comments

@jniles
Copy link
Collaborator

jniles commented Feb 27, 2017

The running totals on the accounts report does not work in a multi-connection environment. The SET balance := 0 syntax only applies to individual MySQL connections which are taken randomly from a pool. Therefore, chaining db.exec() calls via .then() promise chains does not guarantee that you will receive the same connection with the initialized variable.

The running total should be redesigned with this consideration in mind - a transaction may yield the correct result, but a stored procedure or MySQL function would be the best solution to this problem.

@jniles jniles added the Bug label Feb 27, 2017
@jniles jniles self-assigned this Feb 27, 2017
jniles pushed a commit to jniles/bhima that referenced this issue Mar 2, 2017
This commit implements the correct cumulative balance summation for the
accounts report that initializes and updates variables in the same SQL
statement. By maintaining all variables in the same statement, the
variables are ensured to be zeroes out prior to usage and do not spread
over multiple MySQL connections.

This solution, while complex, allows total control over filtering via
our standard filtering solutions.  Placing the query in a Stored
Procedure (another solution to localize the variable to a single MySQL
connection/context) would require that any further filters write a new
interface to the stored procedure.

Closes IMA-WorldHealth#1273.
jniles pushed a commit to jniles/bhima that referenced this issue Mar 2, 2017
This commit implements the correct cumulative balance summation for the
accounts report that initializes and updates variables in the same SQL
statement. By maintaining all variables in the same statement, the
variables are ensured to be zeroes out prior to usage and do not spread
over multiple MySQL connections.

This solution, while complex, allows total control over filtering via
our standard filtering solutions.  Placing the query in a Stored
Procedure (another solution to localize the variable to a single MySQL
connection/context) would require that any further filters write a new
interface to the stored procedure.

Closes IMA-WorldHealth#1273.
sfount pushed a commit that referenced this issue Mar 3, 2017
This commit implements the correct cumulative balance summation for the
accounts report that initializes and updates variables in the same SQL
statement. By maintaining all variables in the same statement, the
variables are ensured to be zeroes out prior to usage and do not spread
over multiple MySQL connections.

This solution, while complex, allows total control over filtering via
our standard filtering solutions.  Placing the query in a Stored
Procedure (another solution to localize the variable to a single MySQL
connection/context) would require that any further filters write a new
interface to the stored procedure.

Closes #1273.
@jniles jniles mentioned this issue Jul 23, 2017
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant