Hi guys,

Agree to revive this thread, it's worth to move forward towards an outcome.
Seeing soft-delete, soft-create, and resilient purge task recovery all
converge on the same underlying need makes a strong case for getting a
proper durable task framework in place.

I have several thoughts on why this fits well and what it's important to cover:
1. Relying on durable, scheduled tasks for hold-period and
grace-period expiration is much cleaner and more predictable for users
than triggering cleanup opportunistically during unrelated REST
requests. If I do the analogy with JMS and Apache ActiveMQ, that was
exactly the reason of RedeliveryPolicy implemented with a scheduler in
ActiveMQ.
2. For soft-delete and staged creates, tasks scheduled for now +
holdPeriod (or gracePeriod) will need a clean way to either be
cancelled or safely no-op if the entity state changes before execution
(e.g., a STAGED table commits to LIVE, or a DELETED table is restored
or explicitly DROP PURGE). Ensuring the API/model should deal with
delayed execution and lightweight state validation at execution time
will be important. If I take another analogy, it's the way Apache
Aries Blueprint is dealing with GracePeriod for blueprint container.
3. As Dmitri noted, current TaskExecutorImpl retires are purely
in-process (up to 3 attempts), clone request-scoped context, and leave
failed or interrupted TaskEntity records orphaned across
restarts/crashes. Moving away from PolarisBaseEntity-coupled tasks
toward lightweight tasks definitions with durable claims,
heartbeats/leases, and retries across nodes would solve that directly.
We can take some inspiration from
https://activemq.apache.org/components/classic/documentation/redelivery-policy.
4. To avoid blocking ongoing work like soft-delete or turning this
into a huge all-at-once migration, we could land the core Tasks
API/SPI + store impl first, wire up one concrete use case (e.g.
durable table cleanup or delayed expiration), and migrate the existing
TaskHandlers incrementally while keeping the remote/delegation
execution option open via the SPI.

Regards
JB

On Thu, Nov 19, 2026 at 12:49 AM Dmitri Bourlatchkov via dev
<[email protected]> wrote:
>
> Hi Alex,
>
> I fully support reviving this thread.
>
> This framework would be useful for resuming failed "traditional" purge
> tasks too [1].
>
> Cheers,
> Dmitri.
>
> [1] https://github.com/apache/polaris/pull/5421#discussion_r4622046827
>
> On Tue, Nov 17, 2026 at 11:46 AM Alexandre Dutra via dev <
> [email protected]> wrote:
>
> > Hi all,
> >
> > In the light of the soft-delete proposal in [5544], and also considering
> > my own suggestion of a soft-create mechanism for staged table creations
> > [1], I think we should revive this thread.
> >
> > An asynchronous task execution framework would be the perfect fit for
> > tasks such as:
> >
> > - Purging a soft-deleted table's files after the hold period elapses, then
> > dropping the table completely;
> >
> > - Purging a staged table's locations after the grace period elapses
> > without the table being effectively created.
> >
> > Together, these proposals could streamline staged creations and soft
> > deletes by taking care of the hard parts automatically, with many added
> > benefits:
> >
> > - Staged creates cannot accidentally overlap anymore;
> > - Soft-deleted tables still keep their locations reserved during the hold
> > period;
> > - Remote signing would be much easier for staged creates and
> > drop-with-purge on Spark;
> > - etc.
> >
> > WDYT?
> >
> > Thanks,
> > Alex
> >
> > [1]: https://lists.apache.org/thread.html/tosyqhk2jb8y3ch06mgg28dg2px9czob
> > [5544]: https://github.com/apache/polaris/pull/5544
> >
> > On 2025-07-29 10:48 UTC Robert Stupp wrote:
> > > Hi,
> > >
> > > (starting w/ a recap for everybody watching this thread)
> > > The goal of this is to have a mechanism to guarantee the _eventual_
> > > execution of a task. That may happen immediately on the same node or
> > > at a later time on another node.
> > > This particular "async reliable tasks" is to ensure that tasks run
> > > eventually in any Polaris node. The related "Delegation Service"
> > > proposal is to let tasks run in a separate, different remote service.
> > > But it requires a "local fallback" in case the remote service is not
> > > available, which would be provided by this proposal.
> > >
> > > Currently, all scheduled and running tasks are "lost", if Polaris is
> > > stopped, killed or crashed. So I'd prefer to get this proposal in
> > > first to address the current issues and have a reliable fallback for
> > > the Delegation Service.
> > >
> > > Considering the current issues, I don't think it's worth the effort to
> > > keep the current implementation.
> > >
> > > Both, this proposal and the Delegation Service, shouldn't rely on
> > > Polaris entities but rather have targeted definitions for the tasks to
> > > execute, which contain exactly (and not more) what the tasks need to
> > > be executed.
> > >
> > > So I think the following steps (approx 1 PR for each) would be:
> > > 1. Add the tasks API (the draft PR [1])
> > > 2. Add the tasks implementation, w/o any persistence integration but
> > > with mock testing
> > > 3. Add persistence integration
> > > 4. Replace current task implementation with the new one
> > >
> > > I'll probably have more details soon-ish.
> > >
> > > Robert
> > >
> > > [1] https://github.com/apache/polaris/pull/2180
> > >
> > >
> > >
> > > On Mon, Jul 28, 2025 at 6:22 AM William Hyun <[email protected]> wrote:
> > > >
> > > > Hey Robert!
> > > >
> > > > Thank you for the draft PR.
> > > > I have taken a look and the general approach seems good to me.
> > > > However, one of my concerns would be the timeline to deliver this new
> > > > task framework refactoring as this could be intrusive due to the scope
> > > > of the change.
> > > > What do you plan as the ETA for delivering this change?
> > > >
> > > > It seems we need to support both the pre-existing (v1) and new task
> > > > framework (v2) until we are sure that v2 is stabilized so that we can
> > > > delete v1.
> > > > With the Delegation Service proposal being a new feature for users, I
> > > > am proposing to include it within the 1.1 release as a small, optional
> > > > extension and also support it in v2 by reusing via implementing v2's
> > > > SPI module as we previously discussed.
> > > > I also have opened a PR demonstrating what the Delegation Service
> > > > looks like here:
> > > >
> > > > - https://github.com/apache/polaris/pull/2193
> > > >
> > > > WDYT?
> > > >
> > > > Bests,
> > > > William
> > > >
> > > > On Thu, Jul 24, 2025 at 11:18 AM Robert Stupp <[email protected]> wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > As discussed on the Polaris Community Sync today, we're aligned that
> > > > > the current tasks handling needs some refactoring.
> > > > >
> > > > > This proposal focuses on the "eventual execution" of a task.
> > > > > Implementations for would follow.
> > > > > The "Delegation Service" [1]  proposal focuses on the execution of
> > > > > tasks "outside" of Polaris.
> > > > >
> > > > > I've pushed a draft PR [2] with the Java interfaces and value types
> > > > > for the API, the SPI (behavior implementation) and store (used by
> > > > > tasks implementations).
> > > > >
> > > > > The only entry point is the `org.apache.polaris.tasks.api.Tasks`
> > > > > interface with a function defining the behavior and providing a
> > > > > parameter object (if necessary), returning a `TaskSubmission`. Call
> > > > > sites _may_ subscribe to a `CompletionStage`, but the idea is that
> > > > > it's rather "fire and forget" and the task behavior does "everything
> > > > > that's needed". This allows the task to be executed on any node.
> > > > > There's no guarantee in any form that a task will run "locally" or
> > any
> > > > > other specific node. Every Polaris node can handle task execution and
> > > > > perform failure/retry handling. Polaris nodes may use a "server"
> > > > > implementation or a "client" implementation or a "remote"
> > > > > implementation - that's defined upon deployment or by configuration
> > > > > (TBD).
> > > > >
> > > > > I think that we can get to a Polaris internal API/SPI that can be
> > > > > leveraged by both proposals.
> > > > > This proposal is implementation and persistence backend agnostic.
> > > > > There could be a "server" implementation that can run tasks, a
> > > > > "client" implementation that can only submit tasks (think: from the
> > > > > polaris-admin tool), and an implementation for the delegation service
> > > > > to execute tasks remotely.
> > > > >
> > > > > I do have a working implementation sitting around locally that's
> > > > > passing tests exercising concurrency, multi-node and failure
> > > > > scenarios. Since there's only a store-implementation for NoSQL, I
> > > > > haven't pushed that yet. Adding a store-implementation that solely
> > > > > uses `BasePersistence``(JDBC) is not such a big deal.
> > > > >
> > > > > If we're okay with the approach in general, I can follow up with a
> > > > > more concrete implementation including the "purge table" use case and
> > > > > maybe another example use case.
> > > > >
> > > > > Robert
> > > > >
> > > > > [1] https://lists.apache.org/thread/ph10th4ocjczpf5gz17mqys4fkp5qrzw
> > > > > [2] https://github.com/apache/polaris/pull/2180
> > > > >
> > > > > On Mon, May 19, 2025 at 12:05 PM Robert Stupp <[email protected]>
> > wrote:
> > > > > >
> > > > > > Yes, each "task behavior" has an ID. I've chosen the term "task
> > > > > > behavior" over "type", because it doesn't only define "what's
> > done" but
> > > > > > also "when" it's done (delay) and "how it behaves" (retries on
> > failures).
> > > > > >
> > > > > > On 14.05.25 04:25, Adnan Hemani wrote:
> > > > > > > Hi Robert,
> > > > > > >
> > > > > > > Firstly, thanks for this document. One quick question: is the
> > `behavior ID` basically the task type? This part was slightly unclear to me.
> > > > > > >
> > > > > > > Best,
> > > > > > > Adnan Hemani
> > > > > > >
> > > > > > >> On May 9, 2025, at 6:07 AM, Robert Stupp <[email protected]>
> > wrote:
> > > > > > >>
> > > > > > >> Hi,
> > > > > > >>
> > > > > > >> Polaris is a service, which has to eventually perform
> > operations asynchronously. Polaris is also meant to be backed by multiple
> > server instances (think: high-availability & load-balancing setups).
> > > > > > >>
> > > > > > >> During runtime, things can go sideways in many ways. Server
> > instances may crash, be killed or whatever... Task executions may fail,
> > because some other remote service fails, configuration values (and
> > credentials) may be wrong or other error situations.
> > > > > > >>
> > > > > > >> Task execution should be resilient to both kinds of scenarios:
> > being able to eventually recover from a "dead/lost node" scenario and to
> > retry failed tasks.
> > > > > > >>
> > > > > > >> Each individual task should also be executed only once.
> > > > > > >>
> > > > > > >> There are also different kinds of tasks with different
> > behaviors: the "function" being executed and the retry behavior.
> > > > > > >>
> > > > > > >> Proposal doc for this:
> > https://www.google.com/url?q=https://docs.google.com/document/d/17D28E2ne5dzOHWc9DJ91Yz3lnQOtgmWaA_TBNdXv0sY/edit?tab%3Dt.0&source=gmail-imap&ust=1747400861000000&usg=AOvVaw3x56ChuB1ga0MelG6URxxi
> > > > > > >>
> > > > > > >> Robert
> > > > > > >>
> > > > > > >>
> > > > > > >> --
> > > > > > >> Robert Stupp
> > > > > > >> @snazy
> > > > > > >>
> > > > > > --
> > > > > > Robert Stupp
> > > > > > @snazy
> > > > > >
> > >
> >

Reply via email to