Skip to content

HBASE-30234: Replication shippedBytes metric overflows to negative due to int truncation of batch size#8467

Open
asdf2014 wants to merge 1 commit into
apache:masterfrom
asdf2014:HBASE-30234
Open

HBASE-30234: Replication shippedBytes metric overflows to negative due to int truncation of batch size#8467
asdf2014 wants to merge 1 commit into
apache:masterfrom
asdf2014:HBASE-30234

Conversation

@asdf2014

Copy link
Copy Markdown
Member

Problem

Several size-tracking variables in the replication source pipeline use int.
Once a WAL entry batch (or a bulk load's referenced store files) exceeds
Integer.MAX_VALUE (~2GB), the value silently overflows: the shippedBytes
JMX metric goes negative and the (negative) size is fed to the bandwidth
throttler, breaking throttling.

Fix

Widen the size to long end-to-end (shipper heap size, tryThrottle /
getNextSleepInterval, MetricsSource#shipBatch, ReplicateContext#size,
and ReplicationSourceWALReader#sizeOfStoreFilesIncludeBulkLoad).

Testing

  • New TestReplicationSizeOverflow and a >2GB case in TestReplicationThrottler.
  • Before/after: reintroducing the int cast makes the store-file test fail with
    expected: <3500000000> but was: <-794967296>.
  • spotbugs:check reports 0 bugs; changed lines are checkstyle-clean.

…e to int truncation of batch size

Several size-tracking variables in the replication source pipeline used int
instead of long, so once a WAL entry batch (or a bulk load's referenced store
files) exceeded Integer.MAX_VALUE (~2GB) the value silently overflowed. This
surfaced as a negative shippedBytes JMX metric and as broken throttling, since
the truncated (often negative) size was handed to the bandwidth throttler.

Widen the size to long end-to-end:
- ReplicationSourceShipper#shipEdits keeps getHeapSize() as long.
- ReplicationSourceInterface/ReplicationSource#tryThrottle and
  ReplicationThrottler#getNextSleepInterval accept a long size.
- MetricsSource#shipBatch takes a long sizeInBytes (sink counters are long).
- ReplicationEndpoint.ReplicateContext#size and its accessors are long.
- ReplicationSourceWALReader#sizeOfStoreFilesIncludeBulkLoad accumulates and
  returns long instead of casting each addition to int.

Add TestReplicationSizeOverflow (store-file-size accumulation, shippedBytes
metric path, ReplicateContext) and a >2GB case in TestReplicationThrottler.
@asdf2014

Copy link
Copy Markdown
Member Author

The large-wave-2 failure looks unrelated to this change. The only failing test is TestProcDispatcher.testRetryLimitOnConnClosedErrors (a LargeTests under hbase.util covering the remote procedure dispatcher), which failed on a 5s Waiter.waitFor timeout — a timing flake rather than anything this patch touches (this PR only widens replication size fields from int to long). It was the only failure out of 1145 tests in that wave, and it passes locally for me. Every other check is green, including general-check (checkstyle/spotbugs/spotless) and small/medium/large-wave-1/large-wave-3. Could a committer please re-run the failed job? Thanks!

@liuxiaocs7

Copy link
Copy Markdown
Member

@asdf2014 Re-running! And #8439 is for this flaky test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants