GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PIP 129: Introduce intermediate state for ledger deletion · Issue #13526 · apache/pulsar

PIP 129: Introduce intermediate state for ledger deletion #13526

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
PIP 129: Introduce intermediate state for ledger deletion#13526
Copy link
Labels
lifecycle/staletype/PIP

Description

@wuzhanpeng
wuzhanpeng
opened on Dec 27, 2021
Issue body actions

Motivation

Related to #13238

Corresponding logic: org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl#internalTrimLedgers

Under the current ledger-trimming design, we need to collect those ledgers that need to be deleted first, and then perform the asynchronous deletion of the ledger concurrently, but we do not continue to pay attention to whether the deletion operation is completed. If the meta-information update has been successfully completed but an error occurs during the asynchronous deletion, the ledger may not be deleted, but at the logical level we think that the deletion has been completed, which will make this part of the data remain in the storage layer forever (such as bk). As the usage time of the cluster becomes longer, the residual data that cannot be deleted will gradually increase.

In order to achieve this goal, we can separate the logic of meta-information update and ledger deletion. In the trimming process, we can first mark which ledgers are deletable, and update the results to the metadatastore. We can perform the deletion of marked ledgers asynchronously in the callback of updating the meta information, so that the original logic can be retained seamlessly. Therefore, when we are rolling upgrade or rollback, the only difference is whether the deleted ledger is marked for deletion.

To be more specific:

  1. for upgrade, only the marker information of ledger has been added, and the logical sequence of deletion has not changed.
  2. for rollback, some ledgers that have been marked for deletion may not be deleted due to the restart of the broker. This behavior is consistent with the original version.

In addition, if the ledger that has been marked is not deleted successfully, the marker will not be removed. So for this part of ledgers, every time trimming is triggered, it will be deleted again, which is equivalent to a check and retry mechanism.

Goal

We need to modify some logic in org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl#internalTrimLedgers so that the ledger deletion logic in ledger-trimming is split into two stages, marking and deleting. Once the marker information is updated to the metadatastore, every trimming will try to trigger the ledger deletion until all the deleteable ledgers are successfully deleted.

API Changes

org.apache.bookkeeper.mledger.ManagedLedger

public interface ManagedLedger {
    ...

    /**
     * Mark deletable ledgers for bookkeeper and offload storage
     *
     * @param deletableLedgerIds
     * @param deletableOffloadedLedgerIds
     */
    void markDeletableLedgers(Collection<Long> deletableLedgerIds, Collection<Long> deletableOffloadedLedgerIds);

    /**
     * Get all deletable ledgers
     *
     * @return all the deletable ledgers of the managed-ledger
     */
    Set<Long> getAllDeletableLedgers();

    /**
     * Get all deletable offloaded ledgers
     *
     * @return all the deletable offloaded ledgers of the managed-ledger
     */
    Set<Long> getAllDeletableOffloadedLedgers();

    /**
     * Check and remove all the deletable ledgers
     */
    void removeAllDeletableLedgers();
}

Implementation

This proposal aims to separate the deletion logic in ledger-trimming, so that ManagedLedgerImpl#internalTrimLedgers is responsible for marking the deletable ledgers and then perform actual ledger deletion according to the metadatastore.

Therefore, the entire trimming process is broken down into the following steps:

  1. mark deletable ledgers and update ledger metadata.
  2. do acutual ledger deletion after metadata is updated.

For step 1, we can store the marker of deletable information in org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl#propertiesMap. When retrieving the deleted ledger information, we can directly query by iterating propertiesMap. If this solution is not accepted, maybe we can create a new znode to store these information, but this approach will not be able to reuse the current design.

For step 2, we can perform the deletion of marked ledgers asynchronously in the callback of updating the meta information. And every trimming will trigger the check and delete for those deleteable ledgers.

Reject Alternatives

None

Activity

  1. wuzhanpeng
    added
    type/PIP
    on Dec 27, 2021
  2. eolivelli commented on Dec 28, 2021

    @eolivelli
    eolivelli
    on Dec 28, 2021
    Contributor
    More actions

    There is no need to add a background operation.
    We can do the deletion in the same thread, after the 'mark' phase.

    Otherwise we will introduce more complexity in understanding when the deletion happens (and you will see many new flaky tests for instance)

  3. eolivelli commented on Dec 28, 2021

    @eolivelli
    eolivelli
    on Dec 28, 2021
    Contributor
    More actions

    We should also take into consideration the rollback procedure in this PIP and the upgrade procedure.

    1. What happens when you upgraded only one part of the brokers?
    2. What happens if I rollback Pulsar to the previous version ?
  4. wuzhanpeng commented on Dec 29, 2021

    @wuzhanpeng
    wuzhanpeng
    on Dec 29, 2021
    ContributorAuthor
    More actions

    There is no need to add a background operation. We can do the deletion in the same thread, after the 'mark' phase.

    Otherwise we will introduce more complexity in understanding when the deletion happens (and you will see many new flaky tests for instance)

    @eolivelli We can delete after marking, but if the broker process happens to be restarted after the marking is completed, or the bookkeeper cluster is in an abnormal state when the ledger is deleting and the deletion cannot be completed normally, then this part of the ledger needs to be rechecked and deleted. If we do not start a background thread, do we have other ways to complete such a check?

  5. liudezhi2098 commented on Dec 30, 2021

    @liudezhi2098
    liudezhi2098
    on Dec 30, 2021
    Contributor
    More actions

    There is no need to add a background operation. We can do the deletion in the same thread, after the 'mark' phase.
    Otherwise we will introduce more complexity in understanding when the deletion happens (and you will see many new flaky tests for instance)

    @eolivelli We can delete after marking, but if the broker process happens to be restarted after the marking is completed, or the bookkeeper cluster is in an abnormal state when the ledger is deleting and the deletion cannot be completed normally, then this part of the ledger needs to be rechecked and deleted. If we do not start a background thread, do we have other ways to complete such a check?

    maybe we can accomplish this in internalTrimLedgers, if the broker process happens to be restarted after the marking is completed, can still find the deleteable ledgers, then need to rechecked and delete.

  6. github-actions commented on Feb 26, 2022

    @github-actions
    github-actionsBot
    on Feb 26, 2022
    More actions

    The issue had no activity for 30 days, mark with Stale label.

  7. github-actions
    added
    lifecycle/stale
    on Feb 26, 2022
  8. github-actions commented on May 29, 2022

    @github-actions
    github-actionsBot
    on May 29, 2022
    More actions

    The issue had no activity for 30 days, mark with Stale label.

  9. eolivelli commented on May 29, 2022

    @eolivelli
    eolivelli
    on May 29, 2022
    Contributor
    More actions

    @dlg99 you are interested in this work, PTAL

  10. github-actions
    removed
    Stale
    on May 30, 2022
  11. horizonzy commented on Jun 6, 2022

    @horizonzy
    horizonzy
    on Jun 6, 2022
    Member
    More actions

    @wuzhanpeng @eolivelli @dlg99 Hi all, we are doing the work at now. There is the new design and the pr already complete.
    #15834
    The new proposal is under discuss, coming soon.

  12. tisonkun commented on Dec 11, 2022

    @tisonkun
    tisonkun
    on Dec 11, 2022
    Member
    More actions

    Superseded by #16569

  13. tisonkun
    closed this as not plannedon Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/staletype/PIP

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.