git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/7] maintenance: store the "last run" time in config

From
Derrick Stolee <stolee@gmail.com>
Date
Aug 26, 2020, 13:34 UTC
Message-ID
<4fe41132-c8f5-6b85-414f-5a1e5fcccdc9@gmail.com>
In-Reply-To
<xmqqh7sqz93k.fsf@gitster.c.googlers.com>
On 8/25/2020 5:52 PM, Junio C Hamano wrote:
Show 12 quoted lines
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
>> I selected the timestamp before the task, as opposed to after the task,
>> for a couple reasons:
>>
>>  1. The time the task takes to execute should not contribute to the
>>     interval between running the tasks.
> 
> ... as long as the run time is sufficiently shorter than the
> interval, that is.  If a task takes 10-30 minutes depending on how
> dirty the repository is, it does not make sense to even try to run
> it every 15 minutes.

Definitely. The lock on the object database from earlier prevents these longer-than-anticipated tasks from stacking.

Show 6 quoted lines
>> If a daily task takes 10 minutes
>>     to run, then every day the execution will drift by at least 10
>>     minutes.
> 
> That is not incorrect per-se, but it does not tell us why drifting
> by 10 minutes is a bad thing.
True.
Show 19 quoted lines
>>  2. If the task fails for some unforseen reason, it would be good to
>>     indicate that we _attempted_ the task at a certain timestamp. This
>>     will avoid spamming a repository that is in a bad state.
> 
> Absolutely.
> 
>> +static void update_last_run(struct maintenance_task *task)
>> +{
>> +	timestamp_t now = approxidate("now");
>> +	struct strbuf config = STRBUF_INIT;
>> +	struct strbuf value = STRBUF_INIT;
>> +	strbuf_addf(&config, "maintenance.%s.lastrun", task->name);
>> +	strbuf_addf(&value, "%"PRItime"", now);
> 
> So is this essentially meant as a human-unreadable opaque value,
> like we have in the commit object header lines?  I do not have a
> strong opinion, but it would be nice to allow curious to casually
> read it.  Perhaps "git config --type=timestamp maintenance.lastrun"
> can be taught to pretty print its value?

Good idea. I will think on this. Of course, we already have --type=expiry-date, which does the opposite. Perhaps this config value should be a human-readable date and then be parsed into a timestamp in-process using git_config_expiry_date()?

I have mixed feelings on using that format, because it can store both a fixed or relative datetime. The *.lastRun config really wants a _fixed_ datetime, but the *.schedule config (in the next patch) would want a _relative_ datetime. This also allows things like "now" or "never", so it presents a lot of flexibility for users. A nightmare to test, but perhaps that flexibility is useful.

(Of course, in another thread you mentioned multiple `crontab` lines, which might make this entire discussion irrelevant. I'll follow up there.)

Thanks, -Stolee

Previous: Junio C HamanoNext: Junio C Hamano
Message 20 of 41 in “[RFC] Maintenance III: background maintenance”
  1. 0/7 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 19, 2020
  2. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 19, 2020
  3. Đoàn Trần Công DanhAug 20, 2020
  4. Derrick StoleeAug 20, 2020
  5. 4/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 19, 2020
  6. Đoàn Trần Công DanhAug 20, 2020
  7. 3/7 maintenance: add --scheduled option and configDerrick Stolee via GitGitGadget, Aug 19, 2020
  8. Đoàn Trần Công DanhAug 20, 2020
  9. Derrick StoleeAug 24, 2020
  10. 5/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 19, 2020
  11. 6/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 19, 2020
  12. 7/7 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 19, 2020
  13. 0/7 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 25, 2020
  14. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 25, 2020
  15. Junio C HamanoAug 25, 2020
  16. Derrick StoleeAug 26, 2020
  17. Junio C HamanoAug 26, 2020
  18. 2/7 maintenance: store the "last run" time in configDerrick Stolee via GitGitGadget, Aug 25, 2020
  19. Junio C HamanoAug 25, 2020
  20. Derrick StoleeAug 26, 2020
  21. Junio C HamanoAug 26, 2020
  22. Derrick StoleeAug 27, 2020
  23. 3/7 maintenance: add --scheduled option and configDerrick Stolee via GitGitGadget, Aug 25, 2020
  24. Junio C HamanoAug 25, 2020
  25. Derrick StoleeAug 26, 2020
  26. Derrick StoleeAug 27, 2020
  27. 4/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 25, 2020
  28. Junio C HamanoAug 25, 2020
  29. Derrick StoleeAug 26, 2020
  30. 6/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 25, 2020
  31. 7/7 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 25, 2020
  32. 5/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 25, 2020
  33. 0/6 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 28, 2020
  34. 2/6 maintenance: add --schedule option and configDerrick Stolee via GitGitGadget, Aug 28, 2020
  35. 4/6 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 28, 2020
  36. 1/6 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 28, 2020
  37. 5/6 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 28, 2020
  38. 6/6 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 28, 2020
  39. 3/6 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 28, 2020
  40. Michal SuchánekAug 26, 2020
  41. Đoàn Trần Công DanhAug 20, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.