Skip to content

Conversation

@hermanschaaf
Copy link
Member

@hermanschaaf hermanschaaf commented Jan 10, 2023

When overwrite-delete-stale write mode is used, the delete stale should exclude incremental tables. We still want delete-stale behavior for non-incremental tables, but incremental tables have the expectation that previously synced rows should remain there.

This also fixes a small bug where we were deleting stale entries twice for managed writers, which was caught by the new test.

@github-actions github-actions bot added fix and removed fix labels Jan 10, 2023
@github-actions github-actions bot added fix and removed fix labels Jan 10, 2023
@hermanschaaf
Copy link
Member Author

The new test is the first time instance of memdb being used by multiple tables at once, and it turned out we had a data race there. I fixed this by adding a lock around the memdb internal map.

@github-actions
Copy link

⏱️ Benchmark results

Comparing with 506d4cc

  • DefaultConcurrencyDFS-2 resources/s: 11,392 ⬆️ 3.60% increase vs. 506d4cc
  • DefaultConcurrencyRoundRobin-2 resources/s: 12,469 ⬆️ 12.41% increase vs. 506d4cc
  • Glob-2 ns/op: 157.2 ⬇️ 21.06% decrease vs. 506d4cc
  • TablesWithChildrenDFS-2 resources/s: 30,753 ⬆️ 18.36% increase vs. 506d4cc
  • TablesWithChildrenRoundRobin-2 resources/s: 29,648 ⬆️ 8.70% increase vs. 506d4cc
  • TablesWithRateLimitingDFS-2 resources/s: 28.09 ⬇️ 0.85% decrease vs. 506d4cc
  • TablesWithRateLimitingRoundRobin-2 resources/s: 839.5 ⬆️ 1.91% increase vs. 506d4cc
  • BufferedScanner-2 ns/op: 9.376 ⬇️ 29.27% decrease vs. 506d4cc
  • LogReader-2 ns/op: 30.73 ⬇️ 12.56% decrease vs. 506d4cc

Copy link
Member

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, added one comment for clarification

if err := p.DeleteStale(ctx, tables, sourceName, syncTime); err != nil {
include := func(t *schema.Table) bool { return true }
exclude := func(t *schema.Table) bool { return t.IsIncremental }
nonIncrementalTables, err := tables.FilterDfsFunc(include, exclude)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are tables already filtered by the glob patterns in the spec?
Making sure we don't return all tables here since we include everything.

Also since include is always true, maybe add only the exclude part for now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, tables are already filtered by glob patterns at this point (previously we were passing all these tables in to delete stale, now we're filtering out the incremental ones from that list first).

FilterDfsFunc is now also used by FilterDfs internally, and that needs both include and exclude.

Copy link
Contributor

@yevgenypats yevgenypats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪄

@kodiakhq kodiakhq bot merged commit d45e230 into main Jan 11, 2023
@kodiakhq kodiakhq bot deleted the incremental-delete-stale branch January 11, 2023 14:11
hermanschaaf pushed a commit that referenced this pull request Jan 11, 2023
🤖 I have created a release *beep* *boop*
---


##
[1.24.2](v1.24.1...v1.24.2)
(2023-01-11)


### Bug Fixes

* Incremental tables should not delete stale
([#594](#594))
([d45e230](d45e230))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants