-
Notifications
You must be signed in to change notification settings - Fork 59
Add batch deletion DAO support for stale metadata cleanup #604
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
93ed290
feat(dao): add batch deletion DAO support for stale metadata cleanup
aead6f1
fix: revert EmbeddedMariaInstance Apple Silicon config, fix checkstyl…
0d1443e
fix(dao): validate cutoffTimestamp format to prevent SQL injection
be1c3d1
feat(dao): add batch deletion delegation methods to EbeanLocalDAO
960e52f
refactor(dao): parameterize Status column name in batch deletion SQL
d3c2a53
refactor(dao): replace SELECT * with explicit column list in batch de…
c448571
fix(dao): add batch size guard to batch deletion DAO methods
178181d
fix(dao): update docs to reflect parameterized column name and explic…
c8635a4
style: fix spotless markdown formatting in spec
69e341f
refactor(dao): resolve Status column name internally in EbeanLocalAccess
NatalliaUlashchick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| DataHub GMA (General Metadata Architecture) is the backend framework for LinkedIn's DataHub metadata search & discovery | ||
| platform. It provides type-safe, schema-driven metadata management with event-driven data consistency across multiple | ||
| storage backends (SQL via Ebean, Elasticsearch for search). Built on LinkedIn's Pegasus data framework and Rest.li for | ||
| REST APIs. | ||
|
|
||
| **Java version**: 1.8 (Java 8) — required, newer versions will cause build failures. | ||
|
|
||
| ## Build Commands | ||
|
|
||
| ```bash | ||
| ./gradlew build # Full build + all tests | ||
| ./gradlew :module-name:build # Build a specific module (e.g., :dao-api, :dao-impl:ebean-dao) | ||
| ./gradlew :module-name:test # Run tests for a specific module | ||
| ./gradlew spotlessCheck # Check code formatting (CI enforced) | ||
| ./gradlew spotlessApply # Auto-fix formatting | ||
| ./gradlew checkstyleMain # Run checkstyle on main sources | ||
| ./gradlew idea # Generate IntelliJ project files | ||
| ``` | ||
|
|
||
| Tests use **TestNG** (not JUnit) as the default test framework across all subprojects. The elasticsearch integration | ||
| tests require Docker. | ||
|
|
||
| **Apple Silicon (M-series Mac)**: Requires `brew install mariadb` and uncommenting three lines in | ||
| `EmbeddedMariaInstance.java` (see `docs/developers.md`). | ||
|
|
||
| ## Module Architecture | ||
|
|
||
| ``` | ||
| core-models/ → Pegasus PDL schemas: Urn, AuditStamp, Url, Time (no Java logic) | ||
| core-models-utils/ → URN utility helpers | ||
| dao-api/ → DAO abstractions (BaseLocalDAO, BaseSearchDAO, BaseBrowseDAO), | ||
| event producers, query utilities, retention policies | ||
| dao-impl/ | ||
| ebean-dao/ → SQL storage via Ebean ORM (EbeanLocalDAO, relationship queries) | ||
| elasticsearch-dao/ → ES 5.x/6.x search implementation | ||
| elasticsearch-dao-7/→ ES 7.x search implementation | ||
| restli-resources/ → Rest.li resource base classes (BaseEntityResource, | ||
| BaseSearchableEntityResource) mapping DAOs to REST endpoints | ||
| validators/ → Schema validators ensuring PDL models conform to GMA conventions | ||
| (AspectValidator, EntityValidator, SnapshotValidator, etc.) | ||
| gradle-plugins/ → Annotation parsing (@gma) and code generation for metadata events | ||
| testing/ → Test infrastructure, ES integration test harness, test models | ||
| ``` | ||
|
|
||
| ## Key Architectural Patterns | ||
|
|
||
| - **Urn (Universal Resource Name)**: `urn:li:entityType:entityKey` — the universal identifier for all entities. Typed | ||
| URN subclasses provide entity-specific keys. | ||
| - **Aspect Union Pattern**: Each entity type defines a Pegasus union of its supported aspects. Validators enforce that | ||
| union members are record types only. | ||
| - **Aspect Versioning**: Version 0 = latest. Each aspect write creates a new immutable version. Retention policies | ||
| (indefinite, time-based, version-based) control history. | ||
| - **Layered Storage**: BaseLocalDAO (SQL, source of truth) → BaseSearchDAO (Elasticsearch, derived index) → | ||
| BaseBrowseDAO (hierarchical navigation). BaseRemoteDAO proxies to other GMS instances. | ||
| - **Event Sourcing**: Writes to LocalDAO trigger MCE/MAE event emission via BaseMetadataEventProducer. The | ||
| `gradle-plugins` auto-generate event PDL schemas from `@gma` annotations on aspect PDL files. | ||
| - **Generic Type Binding**: DAOs are heavily parameterized with generics (`<ASPECT_UNION, URN>`) and validate type | ||
| constraints at construction time using reflection via `ModelUtils`. | ||
|
|
||
| ## Pegasus/Rest.li Data Models | ||
|
|
||
| PDL (Pegasus Data Language) schemas live in `src/main/pegasus/` directories and compile to Java `RecordTemplate` | ||
| classes. Key namespaces: | ||
|
|
||
| - `com.linkedin.common.*` — Core types (Urn, AuditStamp) | ||
| - `com.linkedin.metadata.aspect.*` — Aspect wrappers | ||
| - `com.linkedin.metadata.query.*` — Search/filter structures | ||
| - `com.linkedin.metadata.events.*` — Change tracking types | ||
| - `com.linkedin.metadata.snapshot.*` — Entity snapshots (versioned aspect collections) | ||
|
|
||
| When modifying PDL schemas, the Pegasus gradle plugin regenerates Java bindings automatically during build. | ||
|
|
||
| ## Commit Convention | ||
|
|
||
| Follow [Conventional Commits](https://www.conventionalcommits.org/): `<type>(scope): description` | ||
|
|
||
| Types: `feat`, `fix`, `refactor`, `docs`, `test`, `perf`, `style`, `build`, `ci` | ||
|
|
||
| Max line length: 88 characters. Use imperative present tense, no capitalized first letter, no trailing dot. |
27 changes: 27 additions & 0 deletions
27
dao-api/src/main/java/com/linkedin/metadata/dao/EntityDeletionInfo.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.linkedin.metadata.dao; | ||
|
|
||
| import java.sql.Timestamp; | ||
| import java.util.Map; | ||
| import lombok.Builder; | ||
| import lombok.Value; | ||
|
|
||
|
|
||
| /** | ||
| * A value class that holds deletion-relevant fields for a single entity, used by batch deletion validation. | ||
| * Contains status flags for deletion eligibility checks and all aspect column values for Kafka archival. | ||
| */ | ||
| @Value | ||
| @Builder | ||
| public class EntityDeletionInfo { | ||
|
|
||
| Timestamp deletedTs; | ||
|
|
||
| boolean statusRemoved; | ||
|
|
||
| String statusLastModifiedOn; | ||
|
|
||
| /** | ||
| * All aspect column values (column name → raw JSON string) for Kafka archival by the service layer. | ||
| */ | ||
| Map<String, String> aspectColumns; | ||
| } |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this!