Skip to content

provider: clear provide queue when reprovide strategy changes #10863

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 16, 2025

Conversation

gammazero
Copy link
Contributor

@gammazero gammazero commented Jul 10, 2025

When the currently configured reprovide strategy does not match the previous strategy read from the datastore, then clear the provide queue and update the reprovide strategy that is stored in the datastore.

Testing was done manually.

Depends on ipfs/boxo#978

Closes #10829

When the currently configured reprovide strategy does not match the previous strategy read from the datastore, then clear the reprovide queue and update the reprovide strategy that is stored in the datastore.

Depends on ipfs/boxo#978

Closes #10829
@gammazero gammazero requested a review from a team as a code owner July 10, 2025 07:55
Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

LGTM! We may also want to add a command to allow users to manually purge the provider queue.

@guillaumemichel guillaumemichel changed the title provider: clear reprovide queue when reprovide strategy changes provider: clear provide queue when reprovide strategy changes Jul 10, 2025
gammazero and others added 2 commits July 10, 2025 01:35
Co-authored-by: Guillaume Michel <guillaumemichel@users.noreply.github.com>
@gammazero
Copy link
Contributor Author

gammazero commented Jul 10, 2025

@guillaumemichel

We may also want to add a command to allow users to manually purge the provider queue.

We could, but what is the use case? If the use case is very rare, then a user could always change the reprovide strategy, restart, then change it back and restart again.

@guillaumemichel
Copy link
Contributor

@hsanjuan since you opened #10829, do you think having a command would be useful?

@hsanjuan
Copy link
Contributor

@hsanjuan since you opened #10829, do you think having a command would be useful?

Yeah, I think it would be useful (if not too complicated). It can be useful for debugging purposes. "Is reproviding the cause of my high CPU/network usage?".. the question can be answered quickly by cleaning the queue and seeing if problem resolves at that moment. Might also be useful when you have pinned many things and then unpinned them, but you are nevertheless reproviding them. The "edit config and restart-workaround" will also eliminate other potential explanations for problems and it is not very obvious.

@guillaumemichel
Copy link
Contributor

"Is reproviding the cause of my high CPU/network usage?"

Just to be clear, this PR is clearing the provide queue but not changing anything about reprovides.

The provide process is as follow:

  1. kubo/boxo wants to provide a cid c
  2. c is added to provide queue
  3. when all the cids before c in the queue have been provided c is provided
  4. periodically, every ReprovideInterval c is reprovided
    a. All the cids returned by the KeyChanFunc are reprovided
    b. There is no reprovide queue, but rather the reprovider is iterating on the keys to reprovide
    c. The reprovide process currently cannot be cancelled

Hence, with a command, users would be able to know whether providing is the cause of high CPU/network usage.

Might also be useful when you have pinned many things and then unpinned them, but you are nevertheless reproviding providing them.

In this case it would help, no keys would be provided after the provide queue is cleared (for better or worse). But in any case, unpinned cids would NOT have been reprovided.

@gammazero
Copy link
Contributor Author

@guillaumemichel @hsanjuan I will provide a command/subcommand to clear the provide queue, but I will do this is a separate PR. The command will be provide with a clear subcommand, i.e. ipfs provide clear. This will give us a place to put future commands that affect the provide and reprovide operation. Dose this sound good?

@gammazero gammazero force-pushed the clear-reprovide-queue branch from 5c5293d to 4f5248a Compare July 10, 2025 17:29
Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

ipfs provide clear

That's perfect!

The `provide clear` command clears all items from the provide queue and prints out the number of items removed from the queue. The `quiet` option tells the command not to print output.
@gammazero
Copy link
Contributor Author

gammazero commented Jul 11, 2025

Add provide clear command to clear provide queue

The provide clear command clears all items from the provide queue and prints out the number of items removed from the queue. The quiet option tells the command not to print output.

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

small nits inline

Comment on lines 23 to 24
Subcommands: map[string]*cmds.Command{
"clear": provideClearCmd,
Copy link
Member

@lidel lidel Jul 11, 2025

Choose a reason for hiding this comment

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

💭 in the future we may want to deprecate ipfs routing provide and ipfs routing reprovide have modern version at ipfs provide stat [cid] that returns state of both systems + optional stat per cid (when/why it was provided last time)

Copy link
Contributor Author

@gammazero gammazero Jul 11, 2025

Choose a reason for hiding this comment

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

I can do that, but in a separate PR.

Issue #10865

Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to deprecate ipfs stats provide and ipfs stats reprovide, but probably not ipfs routing provide <cid> since the command allows the user to advertise a provider record matching the cid to the Amino DHT.

Copy link
Contributor Author

@gammazero gammazero Jul 14, 2025

Choose a reason for hiding this comment

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

@guillaumemichel Want to create an issue?

gammazero and others added 7 commits July 11, 2025 12:43
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

ipfs provide clear

That's perfect!

Now that I think again about it, it would be better to group the command (if possible) as a subcommand of ipfs routing provide rather than create the new ipfs provide just to clear the queue.

@gammazero
Copy link
Contributor Author

Now that I think again about it, it would be better to group the command (if possible) as a subcommand of ipfs routing provide rather than create the new ipfs provide just to clear the queue.

The ipfs routing provide command already looks like this:

ipfs routing provide <key>...       - Announce to the network that you are providing given values.

This means that the clear subcommand would instead need to become a flag, or the keyword "clear" will need to be specially recognized as not a CID. I do not like making a --clear flag, because that completely changes the meaning of the existing provide command. Having a specially recognized keyword is just bad.

So, maybe better to have a different subcommand for ipfs routing. How about ipfs routing clear-keys? Other ideas welcome.

@guillaumemichel
Copy link
Contributor

guillaumemichel commented Jul 15, 2025

@gammazero how about a subcommand like in 6b7dacf?

I don't think that clear would be an accepted cid anyway, so we shouldn't have any collision here.

Feel free to revert the commit.

@guillaumemichel guillaumemichel force-pushed the clear-reprovide-queue branch from a76d0a9 to 5eb2fda Compare July 15, 2025 07:17
@gammazero
Copy link
Contributor Author

I don't think that clear would be an accepted cid anyway, so we shouldn't have any collision here.

It is not collision that I worry about, it is this is not how any of the rest of the CLI works, and is therefore strange and unexpected. @lidel Do you have suggestion?

@gammazero gammazero added the need/triage Needs initial labeling and prioritization label Jul 15, 2025
@lidel lidel mentioned this pull request Jul 15, 2025
51 tasks
@lidel
Copy link
Member

lidel commented Jul 15, 2025

Triage notes:

gammazero and others added 3 commits July 15, 2025 08:29
@lidel lidel requested a review from guillaumemichel July 15, 2025 18:50
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Lgtm, automatic queue purging will likely help people who were stuck with all/flag.

Pushed non-functional changes:

  • moved clear command to new EXPERIMENTAL namespace (ipfs provide)
  • updated changelog/docs + wrote basic ipfs provide --help that will help users to discover existing provider-related commands

@gammazero @guillaumemichel If my changes look ok, feel free to merge.

@lidel lidel dismissed guillaumemichel’s stale review July 15, 2025 18:50

let's create ipfs provide and see how it goes

@gammazero gammazero merged commit a22efea into master Jul 16, 2025
16 of 17 checks passed
@gammazero gammazero deleted the clear-reprovide-queue branch July 16, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command to clean reprovider queue
4 participants