forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spannerio): add ReadChangeStreamPartitionDoFn (#10)
* feat: skeleton implementation of read fn Adds skeleton implementation of the ReadChangeStreamPartitionDoFn with a simple test. * feat: adds initial impl for read component Adds initial implementation for read change stream partition component, along with an initial test and a test plan. * test: adds unit test for record mapping Adds unit test for mapping a struct to a data changes record. * refactor: refactor tests * feat: set the correct bounds for consuming SDF Initialises the offset range based on the start and end timestamp of the partition record. * feat: process heartbeat records Adds heartbeat record processing to the read change stream partition dofn. The only thing necessary here is to update the watermark. * chore: add package info to dao and mapper packages * feat: add simple implementation on child partition Adds the first implementation for child partitions, which just updates the watermark based on the start timestamp of the record. * feat: updates metadata table on child split * feat: add change stream restriction tracker Creates custom implementation of change stream restriction tracker which tracks the timestamp position as well as the mode that should be executed. * refactor: add dao impls for change streams Adds method to run change stream queries and update the partition metadata table within a transaction. * test: narrows unit tests for change stream fn Unit tests only the process element method from the dofn. This way we can verify updates to the restriction tracker and watermark estimator. * test: verify tracker / watermark in tests Validates that the restriction tracker and watermark were used to update the correct state in the change streams unit tests. * feat: add DELETE_PARTITION mode and refactor test * test: complete unit test for child partition split Adds assertions for waiting for children, waiting for parents and deleting the current partition. * feat: adds possible state transition From partition query to wait for parents, since in all cases we will need to wait for parents before terminating. * feat: update termination of data / hearbeat record Waits for parents to be deleted before terminating after a data / hearbeat records. On termination, marks itself as finished and deletes itself from the metadata table. * feat: moves the finishing of a partition state To after a result set is consumed. This was not the case for the child partitions, which finished before waiting for the children. * refactor: refactors split case * chore: removes unused file * refactor: decompose read cdc dofn Decomposes read change stream partition do fn into several actions. * feat: process child partitions independently Processes each record within a child partition record independently. * feat: implement merge all parents finished Implements child partition record case for merge when all parents are finished. * test: add test for merge one parent not finished * test: refactor tests for read dofn * tests: test termination case in read dofn * feat: execute based on mode in read dofn Does different things based on the partition mode that is currently saved in the restriction. * refactor: organize partition metadata dao * refactor: refactors tests * feat: implements change stream dao * fix: fix restriction tracker to update correctly The restriction tracker was not updating the restriction on each tryClaim call. This commit fixes this behaviour. * refactor: minor refactor in read dofn * refactor: undo modifications to SpannerConfig * chore: removes solved TODOs * chore: fixes build violations * docs: adds a few comments / todos * feat: handles initial partition Handles the initial partition which should be mapped to null in the change stream query. * fix: fixes the record mapping Fixes the record mapping according to what is being returned by the change stream query. * feat: parameterises change stream query Uses named params and parameterises the change stream query. * docs: adds state graph for dofn Adds documentation for the state graph on the Read Change Stream Partition DoFn. * docs: add TODOs / FIXMEs for missing functionality * Remove linting (#14) * feat: adds it test for read dofn Here we had to change several things: - We had to fix the restriction tracker checkDone() method, not to require the done partition mode. This is because this method gets called when we resume from a previous mode as well. - We had to fix the heartbeat parameter for the change stream dao. It is now specified as millis instead of seconds. - We added debug logging to all the actions. - We fixed a bug in the restriction tracker allowing the mode change from wait_for_child_partitions to finish_partition (it was missing). Co-authored-by: Zoe <zoc@google.com>
- Loading branch information
1 parent
11e3c9e
commit 89c13b8
Showing
49 changed files
with
4,105 additions
and
303 deletions.
There are no files selected for viewing
This file contains 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 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 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 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.