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

HDDS-11239. Fix KeyOutputStream's exception handling when calling hsync concurrently #7047

Merged
merged 13 commits into from
Aug 21, 2024

Conversation

duongkame
Copy link
Contributor

@duongkame duongkame commented Aug 8, 2024

What changes were proposed in this pull request?

When a block (or BlockOutputStream, I'll use them interchangeably in this description) becomes faulty (any exception happens when sending requests to the pipeline), KeyOutputStream will allocate a new Block (as the current block), and hand off all pending changes in the BufferPool to the current block. This is done by KeyOutputStream's handleException.

Two essential changes are needed when allowing KeyOutputStream to be used by multiple threads concurrently.

  1. When hsync is called concurrently, handleException can be called multiple times for a given block. This is different from when KeyOutputStream is fully synchronized. The second handleException on a block call will see the block has been closed already and some assertion that is true in full synchronization is no longer stand.
Screenshot 2024-08-08 at 9 53 23 AM 2. When the first thread finishes calling handleException, it can continue sending normal writes/hsync to the KeyOutputStream while exception handling may be still going on for other threads. These calls will mess up with the ongoing exception handling. Screenshot 2024-08-08 at 10 48 54 AM We need to isolate the current block if it's handling retry handoff. When a block is created to handle retry, it must block all the normal calls (write and hsync) until the last (faulty) block finishes the handoff.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-11239

How was this patch tested?

New tests were added to verify the failure and the fix: TestHSync#testConcurrentExceptionHandling

Before fix: https://github.com/duongkame/ozone/actions/runs/10308913291
After fix:
run 1: 20 x 1 https://github.com/duongkame/ozone/actions/runs/10427687646
run 2: 10x 10 https://github.com/duongkame/ozone/actions/runs/10428271747

Regression test on normal concurrent hsync: https://github.com/duongkame/ozone/actions/runs/10428273927

@duongkame duongkame marked this pull request as ready for review August 8, 2024 23:16
@duongkame duongkame marked this pull request as draft August 10, 2024 01:27
@jojochuang jojochuang added the hbase HBase on Ozone support label Aug 14, 2024
@duongkame duongkame marked this pull request as ready for review August 16, 2024 20:03
@duongkame
Copy link
Contributor Author

I'll rebase when finishing the test on this branch.

@@ -379,7 +380,7 @@ BlockOutputStreamEntry getCurrentStreamEntry() {
* @return the new current open stream to write to
Copy link
Contributor

Choose a reason for hiding this comment

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

update javadoc for the new parameter. When should it be true/false?

Copy link
Contributor

@jojochuang jojochuang left a comment

Choose a reason for hiding this comment

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

apart from a few questions it looks good.

@jojochuang
Copy link
Contributor

M M IS: Inconsistent synchronization of org.apache.hadoop.hdds.scm.storage.BlockOutputStream.xceiverClientFactory; locked 60% of time Unsynchronized access at BlockOutputStream.java:[line 575]

@duongkame
Copy link
Contributor Author

Copy link
Contributor

@jojochuang jojochuang left a comment

Choose a reason for hiding this comment

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

+1

@jojochuang
Copy link
Contributor

seems to be failing consistently: TestHSync.testUncommittedBlocks:515 expected: but was:

I wonder if it's related to the new commit just merged #7074

writes = runConcurrentWriteHSyncWithException(file, out, data, syncerThreads, errors, errorInjector);
}
validateWrittenFile(file, fs, data, writes);
fs.delete(file, false);
Copy link
Contributor

@chungen0126 chungen0126 Aug 21, 2024

Choose a reason for hiding this comment

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

seems to be failing consistently: TestHSync.testUncommittedBlocks:515 expected: but was:

I wonder if it's related to the new commit just merged #7074

To address the failure in TestHsync#testUncommittedBlocks, ensure that the deletedTable is empty after fs.delete(file, false);
Rebase to master and add a line after fs.delete(file, false); to wait KeyDeletingService to clean up the deletedTable.

      waitForEmptyDeletedTable();

@duongkame
Copy link
Contributor Author

seems to be failing consistently: TestHSync.testUncommittedBlocks:515 expected: but was:

I wonder if it's related to the new commit just merged #7074

Got it. Fixed as @chungen0126 suggested.

@jojochuang jojochuang merged commit 7f47535 into apache:master Aug 21, 2024
39 checks passed
@jojochuang
Copy link
Contributor

Merged. Thanks @duongkame for the patch and @smengcl @chungen0126 for reviews!

errose28 added a commit that referenced this pull request Aug 23, 2024
* master:
  HDDS-11081. Use thread-local instance of FileSystem in Freon tests (#7091)
  HDDS-11333. Avoid hard-coded current version in upgrade/xcompat tests (#7089)
  Mark TestPipelineManagerMXBean#testPipelineInfo as flaky
  Mark TestAddRemoveOzoneManager#testForceBootstrap as flaky
  HDDS-11352. HDDS-11353. Mark TestOzoneManagerHAWithStoppedNodes as flaky
  HDDS-11354. Mark TestOzoneManagerSnapshotAcl#testLookupKeyWithNotAllowedUserForPrefixAcl as flaky
  HDDS-11355. Mark TestMultiBlockWritesWithDnFailures#testMultiBlockWritesWithIntermittentDnFailures as flaky
  HDDS-11227. Use server default key provider to encrypt/decrypt keys from multiple OMs. (#7081)
  HDDS-11316. Improve Create Key and Chunk IO Dashboards (#7075)
  HDDS-11239. Fix KeyOutputStream's exception handling when calling hsync concurrently (#7047)
errose28 added a commit to errose28/ozone that referenced this pull request Aug 26, 2024
…an-on-error

* HDDS-10239-container-reconciliation: (428 commits)
  HDDS-11081. Use thread-local instance of FileSystem in Freon tests (apache#7091)
  HDDS-11333. Avoid hard-coded current version in upgrade/xcompat tests (apache#7089)
  Mark TestPipelineManagerMXBean#testPipelineInfo as flaky
  Mark TestAddRemoveOzoneManager#testForceBootstrap as flaky
  HDDS-11352. HDDS-11353. Mark TestOzoneManagerHAWithStoppedNodes as flaky
  HDDS-11354. Mark TestOzoneManagerSnapshotAcl#testLookupKeyWithNotAllowedUserForPrefixAcl as flaky
  HDDS-11355. Mark TestMultiBlockWritesWithDnFailures#testMultiBlockWritesWithIntermittentDnFailures as flaky
  HDDS-11227. Use server default key provider to encrypt/decrypt keys from multiple OMs. (apache#7081)
  HDDS-11316. Improve Create Key and Chunk IO Dashboards (apache#7075)
  HDDS-11239. Fix KeyOutputStream's exception handling when calling hsync concurrently (apache#7047)
  HDDS-11254. Reconcile commands should be handled by datanode ReplicationSupervisor (apache#7076)
  HDDS-11331. Fix Datanode unable to report for a long time (apache#7090)
  HDDS-11346. FS CLI gives incorrect recursive volume deletion prompt (apache#7102)
  HDDS-11349. Add NullPointer handling when volume/bucket tables are not initialized (apache#7103)
  HDDS-11209. Avoid insufficient EC pipelines in the container pipeline cache (apache#6974)
  HDDS-11284. refactor quota repair non-blocking while upgrade (apache#7035)
  HDDS-9790. Add tests for Overview page (apache#6983)
  HDDS-10904. [hsync] Enable PutBlock piggybacking and incremental chunk list by default (apache#7074)
  HDDS-11322. [hsync] Block ECKeyOutputStream from calling hsync and hflush (apache#7098)
  HDDS-11325. Intermittent failure in TestBlockOutputStreamWithFailures#testContainerClose (apache#7099)
  ...

Conflicts:
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerCheck.java
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
errose28 added a commit to errose28/ozone that referenced this pull request Aug 28, 2024
…rrupt-files

* HDDS-10239-container-reconciliation: (61 commits)
  HDDS-11081. Use thread-local instance of FileSystem in Freon tests (apache#7091)
  HDDS-11333. Avoid hard-coded current version in upgrade/xcompat tests (apache#7089)
  Mark TestPipelineManagerMXBean#testPipelineInfo as flaky
  Mark TestAddRemoveOzoneManager#testForceBootstrap as flaky
  HDDS-11352. HDDS-11353. Mark TestOzoneManagerHAWithStoppedNodes as flaky
  HDDS-11354. Mark TestOzoneManagerSnapshotAcl#testLookupKeyWithNotAllowedUserForPrefixAcl as flaky
  HDDS-11355. Mark TestMultiBlockWritesWithDnFailures#testMultiBlockWritesWithIntermittentDnFailures as flaky
  HDDS-11227. Use server default key provider to encrypt/decrypt keys from multiple OMs. (apache#7081)
  HDDS-11316. Improve Create Key and Chunk IO Dashboards (apache#7075)
  HDDS-11239. Fix KeyOutputStream's exception handling when calling hsync concurrently (apache#7047)
  HDDS-11254. Reconcile commands should be handled by datanode ReplicationSupervisor (apache#7076)
  HDDS-11331. Fix Datanode unable to report for a long time (apache#7090)
  HDDS-11346. FS CLI gives incorrect recursive volume deletion prompt (apache#7102)
  HDDS-11349. Add NullPointer handling when volume/bucket tables are not initialized (apache#7103)
  HDDS-11209. Avoid insufficient EC pipelines in the container pipeline cache (apache#6974)
  HDDS-11284. refactor quota repair non-blocking while upgrade (apache#7035)
  HDDS-9790. Add tests for Overview page (apache#6983)
  HDDS-10904. [hsync] Enable PutBlock piggybacking and incremental chunk list by default (apache#7074)
  HDDS-11322. [hsync] Block ECKeyOutputStream from calling hsync and hflush (apache#7098)
  HDDS-11325. Intermittent failure in TestBlockOutputStreamWithFailures#testContainerClose (apache#7099)
  ...

Conflicts:
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hbase HBase on Ozone support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants