Skip to content

Commit 27671a7

Browse files
lfranckeclaude
andcommitted
fix: Tune NiFi startup defaults (election timeout, archive retention)
- Remove the operator override of nifi.cluster.flow.election.max.wait.time, letting NiFi's upstream default of 5 mins take effect. The previous 1-min override was left over from a "for testing" TODO in the operator and may have caused flow election to settle on incomplete vote sets in cold-start scenarios. - Set nifi.content.repository.archive.max.retention.period to "3 days". Previously empty, which NiFi interprets as Long.MAX_VALUE and disables time-based archive purge entirely. Without a time-based ceiling the content archive directory can accumulate millions of files, which makes the synchronous startup directory scan in FileSystemRepository very slow. Users requiring a longer content-replay window can override via configOverrides. The provenance audit trail is stored separately and is unaffected by this setting. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e691312 commit 27671a7

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ All notable changes to this project will be documented in this file.
1717
Previously, arbitrary keys were silently accepted but ignored ([#921]).
1818
- Bump `stackable-operator` to 0.110.1 and `kube` to 3.1.0 ([#921]).
1919
- Internal operator refactoring: introduce dereference() and validate() steps in the reconciler ([#935]).
20+
- Default `nifi.cluster.flow.election.max.wait.time` to NiFi's upstream value (`5 mins`) instead of the operator's previous `1 mins`. The operator no longer sets this property explicitly; the previous shorter value was left over from a TODO marked as "for testing" and may have caused flow election to settle on incomplete vote sets in cold-start scenarios ([#936]).
21+
- Set `nifi.content.repository.archive.max.retention.period` to `3 days` (previously empty, which NiFi interprets as `Long.MAX_VALUE` and effectively disables time-based archive purge). Without a time-based ceiling, the content archive can grow to half the content PVC and accumulate millions of files, which makes the synchronous startup directory scan in `FileSystemRepository.initializeRepository` very slow. Users requiring a longer content-replay window can extend via `configOverrides`. The provenance audit trail is independent of this setting and unaffected ([#936]).
2022

2123
### Fixed
2224

@@ -29,6 +31,7 @@ All notable changes to this project will be documented in this file.
2931
[#924]: https://github.com/stackabletech/nifi-operator/pull/924
3032
[#928]: https://github.com/stackabletech/nifi-operator/pull/928
3133
[#935]: https://github.com/stackabletech/nifi-operator/pull/935
34+
[#936]: https://github.com/stackabletech/nifi-operator/pull/936
3235

3336
## [26.3.0] - 2026-03-16
3437

docs/modules/nifi/pages/usage_guide/operations/graceful-shutdown.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ nifi 2023-11-08 10:52:15,139 INFO [Thread-0] org.apache.nifi.nar.NarAutoLoader N
2121
nifi 2023-11-08 10:52:15,139 INFO [Thread-0] o.a.n.f.r.CompositeExternalResourceProviderService External Resource Provider Service is stopped
2222
nifi 2023-11-08 10:52:15,139 INFO [Thread-0] org.apache.nifi.NiFi Application Server shutdown completed
2323
----
24+
25+
NOTE: For high-throughput clusters (large numbers of in-flight FlowFiles or high provenance event rates), 5 minutes may not be enough time for NiFi to flush the FlowFile write-ahead log and finalize the provenance index.
26+
If `SIGKILL` is consistently reached before NiFi can shut down cleanly, repositories are left in a partially-flushed state, which makes the next startup significantly slower (FlowFile WAL recovery and provenance reindex have more work to do).
27+
Increase `gracefulShutdownTimeout` if you observe `SIGKILL` being issued, or if subsequent restarts take noticeably longer than expected.

docs/modules/nifi/pages/usage_guide/resource-configuration.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,11 @@ A minimal HA setup consisting of 2 NiFi instances has the following https://kube
4646
* `18432Mi` persistent storage
4747

4848
You can find the default resource configuration values in the {crd-docs}/nifi.stackable.tech/NifiCluster/v1alpha1/#spec-nodes-config-resources[NifiCluster reference docs {external-link-icon}^].
49+
50+
== Content archive retention
51+
52+
When a FlowFile's content claim is no longer referenced, NiFi moves the file into an `archive/` subdirectory of the content repository rather than deleting it immediately.
53+
Archived content is what powers *Replay* and *View Content* in the NiFi provenance UI.
54+
The operator configures both a time-based and a size-based purge threshold; the provenance audit trail itself is stored in a separate repository and is not affected by content archive retention.
55+
56+
If the operator defaults don't fit your workload, for example you need a longer replay window, or you want to disable content archiving entirely, override the relevant `nifi.content.repository.archive.*` properties via xref:usage_guide/overrides.adoc[configOverrides].

rust/operator-binary/src/config/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,19 @@ pub fn build_nifi_properties(
344344
"nifi.content.repository.directory.default".to_string(),
345345
NifiRepository::Content.mount_path(),
346346
);
347+
// Cap archived content age so the archive directory stays bounded in
348+
// file count. NiFi treats empty as Long.MAX_VALUE, leaving size-based
349+
// purge as the only trigger; that lets the archive grow to whatever
350+
// half the PVC holds, and the startup directory scan in
351+
// FileSystemRepository.initializeRepository scales with file count.
352+
// 3 days covers a Friday-incident-investigated-Monday window for
353+
// content replay; users with longer requirements can extend via
354+
// configOverrides. The percentage-based threshold below acts as a
355+
// safety net if write rate outpaces time-based purge.
356+
// Also see https://github.com/stackabletech/nifi-operator/issues/354
347357
properties.insert(
348358
"nifi.content.repository.archive.max.retention.period".to_string(),
349-
"".to_string(),
359+
"3 days".to_string(),
350360
);
351361
properties.insert(
352362
"nifi.content.repository.archive.max.usage.percentage".to_string(),
@@ -599,11 +609,6 @@ pub fn build_nifi_properties(
599609
"nifi.cluster.node.protocol.port".to_string(),
600610
PROTOCOL_PORT.to_string(),
601611
);
602-
// TODO: set to 1 min for testing (default 5)
603-
properties.insert(
604-
"nifi.cluster.flow.election.max.wait.time".to_string(),
605-
"1 mins".to_string(),
606-
);
607612
properties.insert(
608613
"nifi.cluster.flow.election.max.candidates".to_string(),
609614
"".to_string(),

0 commit comments

Comments
 (0)