Repository navigation
Conversation
`stateManager.GetSince()` is `_devlake_subtask_state.prev_started_at`, the time the previous run of the subtask started. The GitHub convert subtasks compared it against `github_updated_at`, which is when GitHub last changed the record. Those are two different clocks, so a tool record that DevLake wrote or corrected after the previous run was skipped whenever GitHub had not touched it since then, on that run and on every run after it. The tool layer stayed correct while the domain record was missing or stuck on its old status. A closed pull request from 2019 whose `merged` flag a later collection filled in is the clearest case: `github_updated_at` is 2019, `since` is the previous run a few hours ago, so the record never reaches `pull_requests`. Filter on the tool record's own `updated_at` instead. Gorm maintains it on every write, so it means "DevLake last wrote this row", which is what the watermark is. This is what the other plugins already do, what the example in `data_convertor_stateful.go` documents, and what the remaining GitHub convert subtasks (repo, release, account, cicd job) already do. Covers the subtasks whose watermark is on their own table: pull requests, issues, pull request comments, issue comments and runs. The seven that gate on a joined parent table are left alone, since which table should carry their watermark is a separate question. Existing domain records that were already skipped are not healed by this; they need one full sync or re-transform. Closes apache#9150 Signed-off-by: Sadat Nazarli <118483002+dvecy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The GitHub convert subtasks filter their input with
GetSince()is_devlake_subtask_state.prev_started_at— the wall-clock time the previous runof that subtask started.
github_updated_atis when GitHub last changed the record. Comparingthem means a tool record that DevLake wrote or corrected after the previous run is skipped
whenever GitHub has not touched it since then — on that run and on every run after it.
That is #9150: the tool layer is right, the domain record is missing or still
OPENwith noclose/merge dates, and a later successful collection never repairs it.
The clearest case, and the one in the report, is a pull request closed years ago whose
mergedflag a later collection filled in:
github_updated_atis 2019,sinceis a few hours ago, sothe corrected row never reaches
pull_requests.Fix
Filter on the tool record's own
updated_at. Gorm maintains it on every write, so it means"DevLake last wrote this row", which is what the watermark is for. Verified: an upsert that
flips
stateandmergedadvancesupdated_atand leavesgithub_updated_atuntouched.This is not a new convention — it is the one already in use:
dal.Where("updated_at >= ? ", since))StatefulDataConverterdoc comment(
backend/helpers/pluginhelper/api/data_convertor_stateful.go), which uses_tool_jira_issues.updated_at >= ?Changed here are the five GitHub convert subtasks whose watermark is on their own table:
pull requests, issues, pull request comments, issue comments and runs.
Deliberately not changed:
pr_label,pr_issue,pr_commit,pr_review,review,issue_labelandissue_assigneegate on a joined parent table'sgithub_updated_at.Switching those raises a separate question — whether the parent or the child table should carry
the watermark — and I did not want to decide it inside a bug fix. Happy to open a follow-up
issue, or to extend this PR if you prefer it all in one place.
Scope and limits, stated explicitly
updated_atis in the past. One full sync or re-transform reconciles them. This answers thereporter's question about a supported way to reconcile.
updated_atis not indexed on these tables whilegithub_updated_atis. The queries arealready driven by the
repo_id/connection_idpredicate, so the plan is unchanged inpractice; adding an index would be a separate migration if you want one.
BatchSave.lastErrtheory discussed on the issue, and itdoes not depend on any write having failed.
Tests
New
TestGithubPrConvertorIncremental(
backend/plugins/github/e2e/pr_convertor_incremental_test.go) seeds three tool records and a_devlake_subtask_staterow, then runs the realConvert Pull Requestssubtask in incrementalmode:
github_updated_atupdated_atMERGEDOn
mainit fails withexpected: []int{29, 30}/actual: []int{30}— pull request 29 neverreaches the domain layer. With the fix it passes, and 31 is still correctly skipped, so the
watermark keeps doing its job.
DataFlowTester.Subtaskcannot drive this: it flushes_devlake_subtask_stateand forcesFullSyncon every call. The test runs the subtask through a context that preserves the state,the same approach as
plugins/youtrack/e2e/stateful_scenario_test.go.Locally, against PostgreSQL 16:
All plugin e2e suites were also run one at a time against a fresh database, as
scripts/e2e-test-go-plugins.shdoes.dora/e2e,zentao/e2eandschema_e2efail, and theyfail identically on an unmodified checkout of
mainon this machine, so they are unrelated tothis change.
Does this close any open issues?
Closes #9150