Skip to content
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

[SPARK-51724][SS] RocksDB StateStore's lineage manager should be synchronized #50520

Closed
wants to merge 1 commit into from

Conversation

siying
Copy link
Contributor

@siying siying commented Apr 4, 2025

Why are the changes needed?

RocksDB State Store's Lineage Manager currently isn't synchronized, but it can be accessed by both DB loading and maintenance thread. In theory, it can cause wrong lineage:

  1. maintenance thread get current lineage
  2. task commit() adds a lineage from the lienage
  3. maintenance thread does the truncation and store it back

In this case, the new lineage added by 2. is lost.
It should be fixed by simply synchronizing those operations.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Run existing unit tests

Was this patch authored or co-authored using generative AI tooling?

No.

lineage = lineage :+ item
}

def resetLineage(newLineage: Array[LineageItem]): Unit = {
def truncateFromVersion(versionToKeep: Long): Unit = synchronized {
resetLineage(getLineageForCurrVersion().filter(i => i.version >= versionToKeep))
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any other places where these 2 operations were split ?

@@ -1467,8 +1467,7 @@ class RocksDB(
// This is relative aggressive because that even if the uploading succeeds,
// it is not necessarily the one written to the commit log. But we can always load lineage
// from commit log so it is fine.
lineageManager.resetLineage(lineageManager.getLineageForCurrVersion()
.filter(i => i.version >= snapshot.version))
lineageManager.truncateFromVersion(snapshot.version)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess its not easily possible. But any way to add a test to verify correctness across threads here ?

@HyukjinKwon HyukjinKwon changed the title [SPARK-51724] RocksDB StateStore's lineage manager should be synchronized [SPARK-51724][SS] RocksDB StateStore's lineage manager should be synchronized Apr 7, 2025
Copy link
Contributor

@HeartSaVioR HeartSaVioR left a comment

Choose a reason for hiding this comment

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

+1

@HeartSaVioR
Copy link
Contributor

It seems OK with handling the above comments as post review if these are addressable.

Thanks! Merging to master/4.0.

HeartSaVioR pushed a commit that referenced this pull request Apr 8, 2025
…hronized

### Why are the changes needed?
RocksDB State Store's Lineage Manager currently isn't synchronized, but it can be accessed by both DB loading and maintenance thread. In theory, it can cause wrong lineage:
1. maintenance thread get current lineage
2. task commit() adds a lineage from the lienage
3. maintenance thread does the truncation and store it back

In this case, the new lineage added by 2. is lost.
It should be fixed by simply synchronizing those operations.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Run existing unit tests

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #50520 from siying/lineagemanagerrace.

Authored-by: Siying Dong <[email protected]>
Signed-off-by: Jungtaek Lim <[email protected]>
(cherry picked from commit 187adb8)
Signed-off-by: Jungtaek Lim <[email protected]>
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.

3 participants