Commit ca0936b
authored
Handle replication process compatible table creation in tables-service (#364)
## Summary
<!--- HINT: Replace #nnn with corresponding Issue number, if you are
fixing an existing issue -->
Issue: Create table process does not handle table properties tables
which require replication compatiblity.
Such tables require the `lastUpdatedMillis` timestamp to follow lineage
lineage of Primary tables. Since primary tables are always created
before Replicated table, `primaryTable.lastUpdatedMillis` >
`replicaTable.lastUpdatedMillis`.
Table commits on replica containing snapshots from Primary table fails
as commit process requires snapshot.timestamp > table.lastUpdatedMillis.
Fix: Allow table creation process to set the `lastUpdatedMillis` field
in table metadata by passing a new field in table property via
`properties.last-updates-ms`. This is only application for tables
requiring replication (should have property.isReplicatedTable`)
- [ ] Client-facing API Changes
- [x] Internal API Changes
- [ ] Bug Fixes
- [x] New Features
- [ ] Performance Improvements
- [ ] Code Style
- [ ] Refactoring
- [ ] Documentation
- [ ] Tests
For all the boxes checked, please include additional details of the
changes made in this pull request.
## Testing Done
Docker testing:
1. Create Replica table with isReplicatedProperty = true - passed and
last-updated-ms (lastUpdatedMillis) is reflected in table metadata
2. Create Primary table with isReplicatedProperty = true - passed and
last-updated-ms (lastUpdatedMillis) is reflected in table metadata
3. Create Primary table with isReplicatedProperty = false - passed and
last-updated-ms (lastUpdatedMillis) is set to currentTimestamp
CRUD operation in tables succeed
```
scala> spark.sql("insert into db.active_replica6 values('a', 'b')").show()
++
||
++
++
scala> spark.sql("select * from db.active_replica6").show()
+---+----+
| id|name|
+---+----+
| a| b|
+---+----+
scala> spark.sql("show tblProperties db.active_replica6").show(100, false)
+------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
|key |value |
+------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
|openhouse.lastModifiedTime |1755215715485 |
|openhouse.tableUUID |2a02f33a-ad9b-4677-8c57-8e3b8326567d |
|openhouse.tableUri |LocalHadoopCluster.db.active_replica6 |
|openhouse.creationTime |1755134384295 |
|openhouse.tableId |active_replica6 |
|write.metadata.delete-after-commit.enabled|true |
|key |value |
|openhouse.tableLocation |/data/openhouse/db/active_replica6-2a02f33a-ad9b-4677-8c57-8e3b8326567d/00001-d282fa1a-684f-4370-aaf1-6fc4c0911a6d.metadata.json|
|write.metadata.previous-versions-max |28 |
|openhouse.tableCreator |openhouse |
|openhouse.tableType |PRIMARY_TABLE |
|policies | |
|openhouse.databaseId |db |
|openhouse.isTableReplicated |true |
|openhouse.clusterId |LocalHadoopCluster |
|format |iceberg/orc |
|openhouse.tableVersion |/data/openhouse/db/active_replica6-2a02f33a-ad9b-4677-8c57-8e3b8326567d/00000-bb85c6c7-b879-4d85-9cf1-71cee6e81223.metadata.json|
|current-snapshot-id |1205631819648875310 |
|last-updated-ms |1755134384295 |
|write.format.default |orc |
|write.parquet.compression-codec |zstd |
|openhouse.appended_snapshots |1205631819648875310 |
+------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------+
scala> spark.sql("drop table db.active_replica6").show()
++
||
++
++
scala> spark.sql("drop table db.active_replica7").show()
++
||
++
++
```
<img width="1115" height="896" alt="Screenshot 2025-08-13 at 6 21 38 PM"
src="https://github.com/user-attachments/assets/5cad1ebb-f139-4994-8e14-da4e0e26a2e0"
/>
<!--- Check any relevant boxes with "x" -->
- [x] Manually Tested on local docker setup. Please include commands
ran, and their output.
- [x] Added new tests for the changes made.
- [ ] Updated existing tests to reflect the changes made.
- [ ] No tests added or updated. Please explain why. If unsure, please
feel free to ask for help.
- [ ] Some other form of testing like staging or soak time in
production. Please explain.
For all the boxes checked, include a detailed description of the testing
done for the changes made in this pull request.
# Additional Information
- [ ] Breaking Changes
- [ ] Deprecations
- [ ] Large PR broken into smaller PRs, and PR plan linked in the
description.
For all the boxes checked, include additional details of the changes
made in this pull request.1 parent 40e69dd commit ca0936b
File tree
12 files changed
+464
-13
lines changed- cluster/storage/src/main/java/com/linkedin/openhouse/cluster/storage
- hdfs
- local
- s3
- iceberg/openhouse/internalcatalog/src
- main/java/com/linkedin/openhouse/internal/catalog
- utils
- test/java/com/linkedin/openhouse/internal/catalog
- services/tables/src
- main/java/com/linkedin/openhouse/tables/api/validator/impl
- test/java/com/linkedin/openhouse/tables
- e2e/h2
- mock/api
12 files changed
+464
-13
lines changedLines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
71 | 85 | | |
cluster/storage/src/main/java/com/linkedin/openhouse/cluster/storage/local/LocalStorageClient.java
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
153 | 167 | | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
102 | 116 | | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
Lines changed: 77 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| 22 | + | |
| 23 | + | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
| |||
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
| 39 | + | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
| |||
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| 81 | + | |
| 82 | + | |
73 | 83 | | |
74 | 84 | | |
75 | 85 | | |
| |||
222 | 232 | | |
223 | 233 | | |
224 | 234 | | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | 235 | | |
231 | 236 | | |
232 | 237 | | |
233 | 238 | | |
234 | 239 | | |
235 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
236 | 251 | | |
237 | 252 | | |
238 | 253 | | |
| |||
301 | 316 | | |
302 | 317 | | |
303 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
304 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
305 | 337 | | |
306 | 338 | | |
307 | 339 | | |
| |||
614 | 646 | | |
615 | 647 | | |
616 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
617 | 689 | | |
Lines changed: 108 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
0 commit comments