Skip to content

Flag to always retain journal #3296

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

Conversation

slinkydeveloper
Copy link
Contributor

Followup of #3295

To use, start with env variable RESTATE_ADMIN__experimental_feature_force_journal_retention=1day.
Moving forward, this should be "on" by default on "dev mode".

Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating this PR @slinkydeveloper. I think the overall changes make sense to me. I've left a few comments/questions/suggestions.

Comment on lines 204 to 234
#[serde(
with = "serde_with::As::<Option<restate_serde_util::DurationString>>",
skip_serializing_if = "Option::is_none",
default
)]
#[cfg_attr(feature = "schemars", schemars(with = "Option<String>"))]
pub workflow_completion_retention: Option<Duration>,

/// # Journal retention
///
/// The journal retention. This applies only to workflow calls, or to idempotent requests.
#[serde(
with = "serde_with::As::<Option<restate_serde_util::DurationString>>",
skip_serializing_if = "Option::is_none",
default
)]
#[cfg_attr(feature = "schemars", schemars(with = "Option<String>"))]
pub journal_retention: Option<Duration>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are those fields handled differently compared to idempotency_retention? It seems that those fields won't be serialized if they are none whereas idempotency_retention will.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of backward compatibility, i can't change idempotency_retention in ServiceMetadata, while these other new fields are all the same.

I added default and DefaultOnNull in ServiceMetadata.idempotency_retention, so we can in future make it optional.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we are adding the idempotency_retention field to the HandlerMetadata in this commit. Is this field related to the ServiceMetadata somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HandlerMetadata.idempotency_retention overrides ServiceMetadata.idempotency_retention, but in theory both should have the same shape, and the default should happen at the end, and not when we store (which is what we're doing now).

…his is by default disabled, and enabled when JournalRetentionPolicy::Retain
 Add business logic to remove journal when purging invocation.
This also includes few sensible changes to the internal API InvocationTargetMetadata, to map its values more easily to what the ServiceInvocation supports.
…ty timeout, abort timeout, journal retention and idempotency retention, private service
…, idempotency retention, workflow retention and private service
… the new MapAsVec with serde

Add new fields in ServiceMetadata/HandlerMetadata.

Introduce new ServiceMetadataResolver.resolve_invocation_attempt_timeouts
…voker. With this change, we now make sure we use for the correct deployment id, the correct inactivity/abort timeouts.
To use, start with env variable `RESTATE_ADMIN__experimental_feature_force_journal_retention=1day`.
Moving forward, this should be "on" by default on "dev mode".
@slinkydeveloper slinkydeveloper force-pushed the flag-to-always-retain-journal branch from fcde01f to 984261c Compare May 26, 2025 16:39
Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this PR @slinkydeveloper. The changes look good to me. I left a comment regarding how to evolve the InvocationTargetMetadata that might make sense to resolve before merging.

Comment on lines +343 to +351
// Little problem here that can lead to some surprising stuff.
//
// When updating a service, and setting the service/handler options (e.g. the idempotency retention, private, etc)
// in the manifest, I override whatever was stored before. Makes sense.
//
// But when not setting these values, we keep whatever was configured before (either from manifest, or from Admin REST API).
// This makes little sense now that we have these settings in the manifest, but it preserves the old behavior.
// At some point we should "break" this behavior, and on service updates simply apply defaults when nothing is configured in the manifest,
// in order to favour people using annotations, rather than the clunky Admin REST API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for capturing this here. This will be super helpful for future me :-)

Comment on lines +95 to +96
/// In case the request has an idempotency key, the `idempotency_retention` caps the maximum `journal_retention` time.
/// In case the request targets a workflow handler, the `workflow_completion_retention` caps the maximum `journal_retention` time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh boy. This ain't easy to understand.

default
)]
#[cfg_attr(feature = "schemars", schemars(with = "Option<String>"))]
pub idempotency_retention: Option<Duration>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference between None and Some(Duration::Zero)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it is for deciding whether a value was explicitly set or not when merging the configurations from the manifest with some defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that's the case, it's different from ServiceMetadata.idempotency_retention because in that case we apply the global default (something i would like to not do anymore....)

Comment on lines +338 to +339
pub idempotency_retention: Option<Duration>,
pub workflow_completion_retention: Option<Duration>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still wondering whether this shouldn't be simply retention and then we have some system defaults for workflow and idempotency calls which are used if no other retention duration was configured. Maybe something for the future I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this level we could do the merge already, that's true. But I want to keep a flat data model here similar to the deployment manifest

Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for updating the PR @slinkydeveloper. The changes look good to me. Let's get it in and benefit from it :-)

@slinkydeveloper slinkydeveloper merged commit a6ee84b into restatedev:main May 28, 2025
27 checks passed
@slinkydeveloper slinkydeveloper deleted the flag-to-always-retain-journal branch May 28, 2025 07:13
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2025
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants