Skip to content

Conversation

@LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Dec 13, 2023

What changes were proposed in this pull request?

In the process of initializing the DB in RocksDBProvider/LevelDBProvider, there is a checkVersion step that may throw an exception. After the exception is thrown, the upper-level caller cannot hold the already opened RockDB/LevelDB instance, so it cannot perform resource cleanup, which poses a potential risk of handle leakage. So this PR manually closes the RocksDB/LevelDB instance when checkVersion throws an exception.

Why are the changes needed?

Should close the RocksDB/LevelDB instance when checkVersion throw Exception

Does this PR introduce any user-facing change?

No

How was this patch tested?

Pass GitHub Actions

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

No

@github-actions github-actions bot added the CORE label Dec 13, 2023
@LuciferYang LuciferYang marked this pull request as draft December 13, 2023 05:45
checkVersion(tmpDb, version, mapper);
try {
checkVersion(tmpDb, version, mapper);
} catch (IOException ioe) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

public static void checkVersion(DB db, StoreVersion newversion, ObjectMapper mapper) throws
IOException {

For LevelDB, it will only throw IOException.

throw new IOException(e.getMessage(), e);
} catch (IOException ioe) {
tmpDb.close();
throw ioe;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

public static void checkVersion(RocksDB db, StoreVersion newversion, ObjectMapper mapper) throws
IOException, RocksDBException {

For RocksDB, it may throw either RocksDBException or IOException

@LuciferYang LuciferYang marked this pull request as ready for review December 13, 2023 08:46
@LuciferYang
Copy link
Contributor Author

friendly ping @dongjoon-hyun Could you help to review this if you have time, thanks ~

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, looks fine to me.

Sorry for the late reply, @LuciferYang .

@dongjoon-hyun
Copy link
Member

Merged to master.

@LuciferYang
Copy link
Contributor Author

Thanks @dongjoon-hyun ~

FMX pushed a commit to apache/celeborn that referenced this pull request Mar 8, 2024
…kVersion throw Exception

### What changes were proposed in this pull request?

Should close the `RocksDB`/`LevelDB` instance when `checkVersion` throw Exception.

Backport [[SPARK-46389][CORE] Manually close the RocksDB/LevelDB instance when checkVersion throw Exception](apache/spark#44327).

### Why are the changes needed?

In the process of initializing the DB in `RocksDBProvider`/`LevelDBProvider`, there is a `checkVersion` step that may throw an exception. After the exception is thrown, the upper-level caller cannot hold the already opened RockDB/LevelDB instance, so it cannot perform resource cleanup, which poses a potential risk of handle leakage. So this PR manually closes the `RocksDB`/`LevelDB` instance when `checkVersion` throws an exception.

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

No.

### How was this patch tested?

CI.

Closes #2369 from SteNicholas/CELEBORN-1315.

Authored-by: SteNicholas <[email protected]>
Signed-off-by: mingji <[email protected]>
SteNicholas added a commit to apache/celeborn that referenced this pull request Apr 23, 2024
…kVersion throw Exception

### What changes were proposed in this pull request?

Should close the `RocksDB`/`LevelDB` instance when `checkVersion` throw Exception.

Backport [[SPARK-46389][CORE] Manually close the RocksDB/LevelDB instance when checkVersion throw Exception](apache/spark#44327).

### Why are the changes needed?

In the process of initializing the DB in `RocksDBProvider`/`LevelDBProvider`, there is a `checkVersion` step that may throw an exception. After the exception is thrown, the upper-level caller cannot hold the already opened RockDB/LevelDB instance, so it cannot perform resource cleanup, which poses a potential risk of handle leakage. So this PR manually closes the `RocksDB`/`LevelDB` instance when `checkVersion` throws an exception.

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

No.

### How was this patch tested?

CI.

Closes #2369 from SteNicholas/CELEBORN-1315.

Authored-by: SteNicholas <[email protected]>
Signed-off-by: mingji <[email protected]>
SteNicholas added a commit to apache/celeborn that referenced this pull request Apr 23, 2024
…kVersion throw Exception

### What changes were proposed in this pull request?

Should close the `RocksDB`/`LevelDB` instance when `checkVersion` throw Exception.

Backport [[SPARK-46389][CORE] Manually close the RocksDB/LevelDB instance when checkVersion throw Exception](apache/spark#44327).

### Why are the changes needed?

In the process of initializing the DB in `RocksDBProvider`/`LevelDBProvider`, there is a `checkVersion` step that may throw an exception. After the exception is thrown, the upper-level caller cannot hold the already opened RockDB/LevelDB instance, so it cannot perform resource cleanup, which poses a potential risk of handle leakage. So this PR manually closes the `RocksDB`/`LevelDB` instance when `checkVersion` throws an exception.

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

No.

### How was this patch tested?

CI.

Closes #2369 from SteNicholas/CELEBORN-1315.

Authored-by: SteNicholas <[email protected]>
Signed-off-by: mingji <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants