Skip to content

Conversation

@BsoBird
Copy link
Contributor

@BsoBird BsoBird commented Dec 10, 2023

What changes were proposed in this pull request?

Modified the modifier of the cache property in the SplitGroup class to make it non-static.

JIRA: https://issues.apache.org/jira/browse/HIVE-27944

Why are the changes needed?

Since the Properties object implement HashTable interface, all the methods of the HashTable interface are synchronised.
In a multi-threaded environment, a deadlock will occur when propA.equals(propB) and propB.equals(propA) occur at the same time.
The problem can be solved with minimal modification by changing SplitGroup.cache to a non-static property.

Does this PR introduce any user-facing change?

no

Is the change a dependency upgrade?

no

How was this patch tested?

no need. Because this patch doesn't change the execution logic of any code

Since the Properties object implement HashTable interface, all the methods of the HashTable interface are synchronised.

In a multi-threaded environment, a deadlock will occur when propA.equals(propB)  and propB.equals(propA) occur at the same time.
@BsoBird
Copy link
Contributor Author

BsoBird commented Dec 10, 2023

@deniskuzZ @abstractdog Hi.Could you help review this PR?

// TODO This needs to be looked at. Map of Map to Map... Made concurrent for now since split generation
// can happen in parallel.
private static final Map<Map<Path, PartitionDesc>, Map<Path, PartitionDesc>> cache =
private final Map<Map<Path, PartitionDesc>, Map<Path, PartitionDesc>> cache =
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you using Hive4-beta?
If it is possible, can we add a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've looked through the code, and the way I've done it doesn't change any of the logical behaviour of the code. I just defined the cache object as a non-static property to avoid the scenario of multiple threads calling it at the same time.

Copy link
Contributor Author

@BsoBird BsoBird Dec 10, 2023

Choose a reason for hiding this comment

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

Furthermore, if you follow the original definition, there is a high probability of deadlocks when multiple threads access the cache at the same time.

Copy link
Contributor Author

@BsoBird BsoBird Dec 10, 2023

Choose a reason for hiding this comment

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

Since the nature of the problem is that HashTable causes deadlocks in concurrent scenarios, I'm not sure what kind of test case would be appropriate to add ....
We can only conclude that whenever a cache object is accessed concurrently, it will trigger a deadlock almost immediately.
For details on deadlocks, you can check jira, which has deadlock-related logging information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zhangbutao If there's anything else I can provide, please let me know.

Copy link
Member

@deniskuzZ deniskuzZ Jan 3, 2024

Choose a reason for hiding this comment

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

add the SQL you've used to repro the concurrency issue into that q.file
note, in case of iceberg, place the q file under itests/qtest-iceberg

mvn test -Dtest=TestIcebergLlapLocalCliDriver -Dqfile=mytest.q -Drat.skip=true -Dtest.output.overwrite=true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deniskuzZ Hi. @deniskuzZ . My current problem is that I can't reproduce the problem consistently. I haven't worked out a way to reproduce the problem consistently yet. So I have no way to add a q.file test case at the moment.

Copy link
Member

Choose a reason for hiding this comment

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

@BsoBird, could you please share the repro steps that led to the issue? it doesn't have to be consistent. I just want to create at least one test covering that part of the code. At this moment we have 0 coverage.

Copy link
Contributor Author

@BsoBird BsoBird Jan 14, 2024

Choose a reason for hiding this comment

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

@deniskuzZ Just Read IcebergTable. and using hive llap. Before I used this patch, this problem occurred occasionally. After I used this patch, the problem disappeared. However, I'm not currently using a hashMap as a replacement for ConcurrentHashMap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deniskuzZ If it is difficult to override this change with SQL, can we re-run the previous SQL to test the LLAP+ICEBERG reads and writes? Because our change must affect all the SQL that reads and writes to the ICEBERG table, we just need to verify that the output is the same as before.

@sonarqubecloud
Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the [email protected] list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label Mar 15, 2024
@BsoBird
Copy link
Contributor Author

BsoBird commented Mar 15, 2024 via email

@github-actions github-actions bot removed the stale label Mar 16, 2024
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the [email protected] list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label May 15, 2024
@BsoBird
Copy link
Contributor Author

BsoBird commented May 20, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Feel free to reach out on the [email protected] list if the patch is in need of reviews.

1

@github-actions github-actions bot removed the stale label May 21, 2024
@deniskuzZ
Copy link
Member

I can't just approve this without the test. I wanted to repro the issue locally and then create a q test, but I didn't have time.
Do you have some repro steps that could be tried locally (data setup + selects)?

@BsoBird
Copy link
Contributor Author

BsoBird commented Jul 15, 2024

Sir.I'm having a hard time triggering this bug directly via SQL because as of now, I'm not sure how to consistently reproduce the problem. in our production env, after we added the patch.The problem disappeared, so I never looked at how to reproduce the bug. Can we test this class in code without using SQL?

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the [email protected] list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label Sep 14, 2024
@deniskuzZ deniskuzZ removed the stale label Sep 14, 2024
@BsoBird BsoBird closed this by deleting the head repository Oct 8, 2024
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.

4 participants