Resolving consistency issues with volume queries in Formance Ledger
Last updated: November 12, 2025
If you're experiencing flaky tests or consistency issues when posting transactions and then immediately querying volumes, this is likely related to how older versions of Formance Ledger handle Point In Time (PIT) calculations.
Understanding the Issue
In Formance Ledger versions 2.0 and 2.1, when no explicit end time (PIT) is provided in volume queries, the system automatically calculates one based on the current wall clock time (time.Now()). This can cause issues when:
You're writing transactions with future timestamps
The query executes before those future transactions become "past" transactions relative to the auto-calculated end time
Your tests run quickly enough that timing becomes inconsistent
Solutions
Upgrade to Latest Version (Recommended)
The most straightforward solution is to upgrade to Formance Ledger version 2.2 or later. Starting from version 2.2, the end time (PIT) is not automatically defined, eliminating this timing issue.
Specify an Explicit End Time
If you need to continue using an older version, you can resolve the issue by providing an explicit EndTime in your volume queries:
endTime := startTime.Add(time.Minute)
volumeReq := operations.V2GetVolumesWithBalancesRequest{
Ledger: ledgerName,
RequestBody: filter,
StartTime: &startTime,
EndTime: &endTime,
}Adjust Transaction Timestamps
Alternatively, you can modify your test to use past timestamps instead of future ones, ensuring all transactions are in the past relative to the query time.
Data Consistency Guarantee
Formance Ledger provides immediate consistency for all write operations. The system relies on PostgreSQL's ACID properties to ensure that data is completely synchronized after writing. You should never need to use time.Sleep or similar delays to wait for data consistency.
Note: The ledger stores dates with microsecond precision (PostgreSQL's maximum precision). To avoid potential flakiness in tests, consider rounding your dates to microsecond precision.