Skip to content

fix(github_graphql): extract only new raw rows for PRs, issues, deployments and releases - #9443

Open
shaynhornik wants to merge 1 commit into
apache:mainfrom
shaynhornik:fix/github-graphql-stateful-extractors
Open

shaynhornik wants to merge 1 commit into
apache:mainfrom
shaynhornik:fix/github-graphql-stateful-extractors

Conversation

@shaynhornik

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #9427. Four more extractors of github_graphql were built with api.NewApiExtractor, which extracts every raw row of the scope again on every run: Extract Pull Requests, Extract Issues, Extract Deployments and Extract Releases. Their collectors are already stateful, so the raw tables only grow by what changed, but the extraction time grew with the whole history (#9442).

They now use api.NewStatefulApiExtractor, so an incremental run reads only the raw rows added since the previous run. The field mapping is unchanged.

Pull requests and issues follow the REST extractors in plugins/github/tasks:

  • Subtask config: the label patterns go into SubtaskConfig (prType, prComponent; the six issue* patterns), so a change extracts everything again.
  • Child rows: in an incremental run, the labels of a pull request, and the labels and assignees of an issue, are deleted before it is extracted again. Otherwise a label removed on GitHub would stay.

Reviews, reviewers and pull request commits are not deleted. They are upserted as before, and the REST plugin does not delete them either.

When every row is still extracted:

  • a full sync;
  • the first run after the upgrade, once (there is no extractor state yet);
  • after a change of the patterns above.

Extract Users is left as it is: its collector is not stateful and rewrites its raw table on every run.

Does this close any open issues?

Closes #9442

Tests

New e2e tests in plugins/github_graphql/e2e/extractor_incremental_test.go, one per extractor. Each builds its raw rows in the test and runs the subtask with its state kept:

  1. With no stored state, every raw row is extracted.
  2. After a raw row is added for an updated record, only that record is written. The other one keeps its updated_at (pull requests, issues, deployments) or is not restored after being deleted (releases, whose updated_at column holds the release's own date).
  3. Pull requests and issues: the labels and assignees the record lost are gone, and a pattern change extracts every row again.
  4. A full sync extracts every row, and the newest raw row wins.

Against the old extractors all four tests fail. Removing a child-row delete or the SubtaskConfig fails the matching assertion.

Run locally:

  • go test ./plugins/github_graphql/e2e/... on MySQL 8.4 and PostgreSQL 18.7, and the new tests 6 times on each.
  • go test ./plugins/github_graphql/tasks/...
  • go vet and golangci-lint v2.15.0 on the plugin.

Not run: the full unit and e2e suites, and a real collection against GitHub.

Other Information

  • One thing this does not change: a full sync replays every raw row, including older versions of the same pull request or issue, so a label that was removed can come back until the record is extracted again. The REST extractors behave the same way.
  • runExtractJobs in the existing job test now calls the shared helper runSubtaskKeepingState.

Generated-by: Claude Code (Claude Fable 5.2). I reviewed and tested the change.

🤖 Generated with Claude Code

…yments and releases

Extract Pull Requests, Extract Issues, Extract Deployments and Extract
Releases used api.NewApiExtractor, which extracts every raw row of the
scope again on every run. They now use api.NewStatefulApiExtractor, so
an incremental run reads only the raw rows added since the previous one.

The label patterns of the scope config are part of the subtask config, so
a change extracts everything again. The labels of a pull request, and the
labels and assignees of an issue, are replaced when it is extracted again.

Closes apache#9442

Generated-by: Claude Code (Claude Fable 5.2)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][github_graphql] Extract Pull Requests, Issues, Deployments and Releases read and rewrite the full raw table on every run

1 participant