Repository navigation
Description
BUG REPORT
Describe the bug
Summary: We use entryLogPerLedgerEnabled:"true" option in environments that have SSDs/NVMes to exploit drive parallelism and it provides significant improvements (as suggested in documentation). However, under high throughput workloads (1GBps, 6 Bookies, 3 replicas), our experiments showed us that there is a consistent problem with this option in which, at some point, makes the ledger volume to run out of storage space. Concretely, at some point one entry log file does not get rotated (i.e., flushRotatedLogs() method does not get invoked in EntryLogManagerForEntryLogPerLedger) while the system continues writing data and generating more entry log files. When this happens, and given that the removal of unnecessary (truncated) entry logs is sequential by entry log id, the GC Thread cannot continue progressing deleting entry logs. This eventually leads to the ledger volume to fill up. This problem was first detected on Bookkeeper 4.11.1 but we also reproduced it in Bookkeeper 4.14.0.
Next, we expose a more detailed explanation with real logs of the issue. Everything works well for some time (minutes or hours, depending on the load) until we detect some ledger activity like this:
(ENTRY LOG ID 1261)
λ grep "Created new entry log file\|Synced" bookkeeper-server-0.log | grep "1261"
2021-05-09 14:35:25,364 - INFO - [pool-4-thread-1:EntryLoggerAllocator@181] - Created new entry log file /bk/ledgers/current/4ed.log for logId 1261.
2021-05-09 14:37:32,800 - INFO - [SyncThread-14-1:EntryLogManagerForEntryLogPerLedger@693] - Synced entry logger 1261 to disk.
(ENTRY LOG ID 1262)
λ grep "Created new entry log file\|Synced" bookkeeper-server-0.log | grep "1262"
2021-05-09 14:35:26,152 - INFO - [pool-4-thread-1:EntryLoggerAllocator@181] - Created new entry log file /bk/ledgers/current/4ee.log for logId 1262.
(ENTRY LOG ID 1263)
λ grep "Created new entry log file\|Synced" bookkeeper-server-0.log | grep "1263"
2021-05-09 14:35:26,419 - INFO - [pool-4-thread-1:EntryLoggerAllocator@181] - Created new entry log file /bk/ledgers/current/4ef.log for logId 1263.
2021-05-09 14:36:33,031 - INFO - [SyncThread-14-1:EntryLogManagerForEntryLogPerLedger@693] - Synced entry logger 1263 to disk.
So, as we can see, there is no Synced entry logger XXX for entry log id 1262, but the subsequent entry logs are rotated. The problem is that it seems that one entry log file not being "rotated" impacts GC for all the subsequent files. That is, if we look at the code that calculates the entryLogger.getLeastUnflushedLogId(), is as follows:
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
Line 1240 in 8dc108b
| synchronized void flushRotatedEntryLog(Long entryLogId) { |
synchronized void flushRotatedEntryLog(Long entryLogId) {
entryLogsStatusMap.replace(entryLogId, true);
while ((!entryLogsStatusMap.isEmpty()) &&(entryLogsStatusMap.get(entryLogsStatusMap.firstKey()))) {
long leastFlushedLogId = entryLogsStatusMap.firstKey();
entryLogsStatusMap.remove(leastFlushedLogId);
leastUnflushedLogId = leastFlushedLogId + 1;
}
}
As you can see, flushRotatedEntryLog is only going to make progress assuming that each an every of the entry log files have been rotated. If just one of them is not rotated, then it stops updating leastUnflushedLogId, which makes the GC not deleting entry logs beyond that point:
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
Line 589 in 25264f9
| long curLogId = entryLogger.getLeastUnflushedLogId(); |
For that entry log 1262, we see this message multiple times along the experiment:
2021-05-09 14:35:31,942 - DEBUG - [SyncThread-14-1:EntryLogManagerBase@129] - Flush and sync current entry logger 1262
...
2021-05-09 15:07:31,831 - DEBUG - [SyncThread-14-1:EntryLogManagerBase@129] - Flush and sync current entry logger 1262
Again, there is no sign of the message Synced entry logger XXXX to disk for that entry log file. This explains why the GC stopped, which makes sense given the current logic. But we don't know why the rotation of that entry log 1262 did not complete. Another question is whether GC for any subsequent entry log file should be stuck just because one of them is making slower progress in getting rotated.
Note that this problem only appears when entryLogPerLedgerEnabled:"true", so disabling that option solves the problem but at the cost of not being able to exploit the parallelism of SSDs/NVMe drives.
To Reproduce
Inducing a high load (+500MBps) on a Bookie with entryLogPerLedgerEnabled:"true", we normally get this error.
Expected behavior
A Bookie with entryLogPerLedgerEnabled:"true" should be able to continue garbage collecting entry log files even though one of the previous entry log files has not been yet rotated.
Screenshots
In this screenshot you can see the behavior related to this issue. As you can see, the Disk Usage of the ledger volume for few Bookies continues to grow until they get in read-only mode, whereas others are still handling properly GC activity:
Additional context
n/a

Activity
dlg99 commentedon Jun 7, 2021
@reddycharan any suggestions here? Do you still use ELPL?
@RaulGracia I don't remember all details of the ELPL/compaction and work that happened afterwards, I'd start with checking:
major/minor compaction intervals, and flushInterval. I am not sure if ledgerStorageClass affects this, but I think SortedLedgerStorage and InterleavedLedgerStorage should work.
In case you are trying to repro it in unit tests, I am curious if ledgers with TTL < flushInterval are the reason for this somehow..
fpj commentedon Jun 10, 2021
@dlg99 any particular why you and others don't use this option? We are observing much higher performance with
entryLogPerLedgerEnabled:"true"in the hardware we are testing with. I'm curious to know why this is not popular given the performance benefit.eolivelli commentedon Jun 10, 2021
@fpj I believe that the problem is that no one knows about it :-)
In general in BK we have the problem that there is no advertising about new features
We are doing some internal testing at DataStax for this option, especially for the fact that with this option it is easier that when you delete a ledger it is deleted from disk more promptly (see BP-45).
eolivelli commentedon Jun 10, 2021
@diegosalvi @nicoloboschi are you enabling this option in production for BlobIt/EmailSuccess ?
dlg99 commentedon Jun 11, 2021
@fpj ELPL gets tricky if you don't know size/number of ledgers. I.e. in multi tenants cluster tenants can end up with too many small ledgers (or many tenants/topics in pulsar with ledger rotation policy on the schedule) + large disk.
I don't remember all the context from the time when ELPL was implemented, I think the following factors should be considered:
maybe something else.
I do agree that reduced write amplification (no compaction) helps (helped in the env it was developed for - large ledgers of predictable sizes, multiple SSDs, etc).
If you are looking for the lessons learned with ELPL, I'd suggest reaching out to @reddycharan and @jvrao
OlegKashtanov commentedon Jun 16, 2021
I reproduced that issue using Bookkeeper benchmark tool.
The following deployment and test steps:
Configuration
Deployment steps
2021-06-11 08:10:19,837 - WARN - [BookieWriteThreadPool-OrderedExecutor-7-0:WriteEntryProcessorV3@73] - BookieServer is running as readonly mode, so rejecting the request from the client!RaulGracia commentedon Oct 15, 2021
Closed via #2779.