Skip to content

Commit dcdcdd8

Browse files
lfranckeclaudemaltesander
authored
fix: Tune NiFi startup defaults (election timeout, archive retention) (#936)
* 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> * fix(smoke_v2): adapt snapshot to default changes * fix(tests): override nifi.cluster.flow.election.max.wait.time to "10 secs" to avoid test timeouts (5min defaualt). --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Malte Sander <malte.sander.it@gmail.com>
1 parent 2b66320 commit dcdcdd8

16 files changed

Lines changed: 66 additions & 8 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(),

tests/templates/kuttl/cluster-sync-cs-bug/20-install-nifi.yaml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ spec:
186186
nifi.properties:
187187
nifi.web.https.sni.required: "false"
188188
nifi.web.https.sni.host.check: "false"
189+
# Quicker startup, and we only have a single node
190+
nifi.cluster.flow.election.max.wait.time: "10 secs"
189191
podOverrides:
190192
spec:
191193
initContainers:

tests/templates/kuttl/cluster_operation/20-install-nifi.yaml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ spec:
5050
gracefulShutdownTimeout: 1m
5151
logging:
5252
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
53+
configOverrides:
54+
"nifi.properties":
55+
# Quicker startup, and we only have a single node
56+
"nifi.cluster.flow.election.max.wait.time": "10 secs"
5357
roleGroups:
5458
default:
5559
replicas: 2

tests/templates/kuttl/custom-components-git-sync/30_install-nifi.yaml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ spec:
6767
config:
6868
logging:
6969
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
70+
configOverrides:
71+
"nifi.properties":
72+
# Quicker startup, and we only have a single node
73+
"nifi.cluster.flow.election.max.wait.time": "10 secs"
7074
roleConfig:
7175
listenerClass: external-unstable
7276
podOverrides:

tests/templates/kuttl/external-access/30_nifi.yaml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ spec:
5353
config:
5454
logging:
5555
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
56+
configOverrides:
57+
"nifi.properties":
58+
# Quicker startup, and we only have a single node
59+
"nifi.cluster.flow.election.max.wait.time": "10 secs"
5660
roleConfig:
5761
listenerClass: test-external-unstable-$NAMESPACE
5862
roleGroups:

tests/templates/kuttl/ldap/12-install-nifi.yaml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ spec:
5454
gracefulShutdownTimeout: 1m
5555
logging:
5656
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
57+
configOverrides:
58+
"nifi.properties":
59+
# Quicker startup, and we only have a single node
60+
"nifi.cluster.flow.election.max.wait.time": "10 secs"
5761
roleConfig:
5862
listenerClass: external-unstable
5963
roleGroups:

tests/templates/kuttl/logging/04-install-nifi.yaml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ spec:
105105
nodes:
106106
config:
107107
gracefulShutdownTimeout: 1m
108+
configOverrides:
109+
"nifi.properties":
110+
# Quicker startup, and we only have a single node
111+
"nifi.cluster.flow.election.max.wait.time": "10 secs"
108112
roleGroups:
109113
automatic-log-config:
110114
replicas: 1

0 commit comments

Comments
 (0)