Production environment encountered a big bug – rounding database storage fields


1. Problem description

In the production environment, sometimes the user‘s income can be paid normally, sometimes it can’t be.
User’s fund involves account module, and fund change mainly involves freezing request, request event, transfer record and operating user’s Fund. The freezing request mainly records the parameters of the request record. The simple point is recharge and withdrawal. The event represents the actual amount of operation. The financial transfer record is equivalent to the log processing of fund changes. Finally, the user’s fund record is actually operated.

2. The problem

The maximum number of decimal places of the defined amount value is 16 digits, while the amount record field of the freezing request table is 9 digits. If the transferred value is greater than 9 digits, the database will perform rounding processing. In the case of rounding, if the amount queried from the frozen table is greater than the actual amount, an error will be reported and an exception will be thrown, which will result in the failure of revenue distribution.

3. Solutions

It is OK to improve the accuracy of the account table field in the frozen table to 16 bits, which solves the problem.

Recommended Today

JS function

1. Ordinary function Grammar: Function function name (){ Statement block } 2. Functions with parameters Grammar: Function function name (parameter list){ Statement block } 3. Function with return value Grammar: Function function name (parameter list){ Statement block; Return value; } Allow a variable to accept the return value after calling the function Var variable name […]