Skip to content

Commit

Permalink
feat(#41): tackled thread pool starving situations
Browse files Browse the repository at this point in the history
Automatic re-scheduling and transaction pipeline recreation.
  • Loading branch information
novoj committed Jun 23, 2024
1 parent 494cd15 commit e27b0c1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 32 deletions.
7 changes: 0 additions & 7 deletions documentation/user/en/operate/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ transaction: # [see Transaction configurati
transactionMemoryRegionCount: 256
walFileSizeBytes: 16MB
walFileCountKept: 8
maxQueueSize: 1K
flushFrequencyInMillis: 1s

cache: # [see Cache configuration](#cache-configuration)
Expand Down Expand Up @@ -489,12 +488,6 @@ This section contains configuration options for the storage layer of the databas
<p>Number of WAL files to keep. Increase this number in combination with `walFileSizeBytes` if you want to
keep longer history of changes.</p>
</dd>
<dt>maxQueueSize</dt>
<dd>
<p>**Default:** `1K`</p>
<p>Size of the catalog queue for parallel transaction. If there are more transaction than the number of free
threads in the pool, the transaction are queued. If the queue is full, the transaction is rejected.</p>
</dd>
<dt>flushFrequencyInMillis</dt>
<dd>
<p>**Default:** `1s`</p>
Expand Down
12 changes: 6 additions & 6 deletions documentation/user/en/operate/reference/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
<UsedTerms>
<h4>Labels used in metrics</h4>
<dl>
<dt>taskName</dt>
<dd><strong>N/A</strong>: N/A</dd>
<dt>fileType</dt>
<dd><strong>File type</strong>: N/A</dd>
<dt>name</dt>
<dd><strong>Logical file name</strong>: N/A</dd>
<dt>fileType</dt>
<dd><strong>File type</strong>: N/A</dd>
<dt>name</dt>
Expand Down Expand Up @@ -99,6 +93,12 @@
<dd><strong>Logical file name</strong>: N/A</dd>
<dt>recordType</dt>
<dd><strong>Record type</strong>: N/A</dd>
<dt>taskName</dt>
<dd><strong>N/A</strong>: N/A</dd>
<dt>fileType</dt>
<dd><strong>File type</strong>: N/A</dd>
<dt>name</dt>
<dd><strong>Logical file name</strong>: N/A</dd>
</dl>
</UsedTerms>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,17 +470,19 @@ public void updateLastFinalizedCatalog(@Nonnull Catalog lastFinalizedCatalog, lo
*/
public void notifyCatalogPresentInLiveView(@Nonnull Catalog livingCatalog) {
final Catalog theLivingCatalog = getLivingCatalog();
Assert.isPremiseValid(
theLivingCatalog.getVersion() < livingCatalog.getVersion(),
"Catalog versions must be in order! " +
"Expected " + theLivingCatalog.getVersion() + ", got " + livingCatalog.getVersion() + "."
);
final long theLastFinalizedVersion = getLastFinalizedCatalogVersion();
Assert.isPremiseValid(
theLastFinalizedVersion >= livingCatalog.getVersion(),
"Catalog versions must be in order! " +
"Expected " + theLastFinalizedVersion + ", got " + livingCatalog.getVersion() + "."
);
if (livingCatalog.getVersion() > 0L) {
Assert.isPremiseValid(
theLivingCatalog.getVersion() < livingCatalog.getVersion(),
"Catalog versions must be in order! " +
"Expected " + theLivingCatalog.getVersion() + ", got " + livingCatalog.getVersion() + "."
);
final long theLastFinalizedVersion = getLastFinalizedCatalogVersion();
Assert.isPremiseValid(
theLastFinalizedVersion >= livingCatalog.getVersion(),
"Catalog versions must be in order! " +
"Expected " + theLastFinalizedVersion + ", got " + livingCatalog.getVersion() + "."
);
}
this.lastAssignedCatalogVersion.updateAndGet(current -> Math.max(current, livingCatalog.getVersion()));
this.livingCatalog.set(livingCatalog);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@ void shouldCorrectlyReportFirstAvailableTimestamp() {

final OffsetDateTime initialTimestamp = OffsetDateTime.now();
writeWal(bigOffHeapMemoryManager, transactionSizes, initialTimestamp);
this.wal.walProcessedUntil(Long.MAX_VALUE);
this.wal.removeWalFiles();

assertEquals(2, offsetConsumer.getCatalogVersions().size());
assertEquals(initialTimestamp.plusMinutes(1), offsetConsumer.getCatalogVersions().get(0));
assertEquals(initialTimestamp.plusMinutes(2), offsetConsumer.getCatalogVersions().get(1));
// only one call would occur with the latest version possible
assertEquals(1, offsetConsumer.getCatalogVersions().size());
assertEquals(3, offsetConsumer.getCatalogVersions().get(0));
}

@Nonnull
Expand All @@ -271,7 +273,7 @@ private CatalogWriteAheadLog createCatalogWriteAheadLogOfSmallSize() {
.build(),
Mockito.mock(Scheduler.class),
offsetConsumer,
null
firstActiveCatalogVersion -> {}
);
}

Expand All @@ -286,7 +288,7 @@ private CatalogWriteAheadLog createCatalogWriteAheadLogOfLargeEnoughSize() {
TransactionOptions.builder().walFileSizeBytes(Long.MAX_VALUE).build(),
Mockito.mock(Scheduler.class),
offsetConsumer,
null
firstActiveCatalogVersion -> {}
);
}

Expand Down
1 change: 0 additions & 1 deletion evita_server/src/main/resources/evita-configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ transaction:
transactionMemoryRegionCount: ${transaction.memoryRegionCount:256}
walFileSizeBytes: ${transaction.walFilSize:16M}
walFileCountKept: ${transaction.walFileCountKept:8}
maxQueueSize: ${transaction.maxQueueSize:1024}
flushFrequencyInMillis: ${transaction.flushFrequencyInMillis:1000}

cache:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ MutationSupplier createSupplier(long startCatalogVersion, @Nullable Long request
/**
* Removes the obsolete WAL files from the catalog storage path.
*/
private long removeWalFiles() {
long removeWalFiles() {
synchronized (this.pendingRemovals) {
final long catalogVersion = this.processedCatalogVersion.get();
final Set<PendingRemoval> toRemove = new HashSet<>(64);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ transaction:
transactionMemoryRegionCount: ${transaction.memoryRegionCount:256}
walFileSizeBytes: ${transaction.walFilSize:16M}
walFileCountKept: ${transaction.walFileCountKept:8}
maxQueueSize: ${transaction.maxQueueSize:1024}
flushFrequencyInMillis: ${transaction.flushFrequencyInMillis:1000}

cache:
Expand Down

0 comments on commit e27b0c1

Please sign in to comment.