hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chia-Ping Tsai (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-17872) Make ByteBufferUtils thread-safe
Date Tue, 04 Apr 2017 11:53:41 GMT

    [ https://issues.apache.org/jira/browse/HBASE-17872?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15955029#comment-15955029
] 

Chia-Ping Tsai commented on HBASE-17872:
----------------------------------------

The exception is shown below. The cell is invalid after MSLAB.
{noformat}
java.lang.IndexOutOfBoundsException
	at java.nio.Buffer.checkIndex(Buffer.java:546)
	at java.nio.HeapByteBuffer.getLong(HeapByteBuffer.java:416)
	at org.apache.hadoop.hbase.util.ByteBufferUtils.toLong(ByteBufferUtils.java:863)
	at org.apache.hadoop.hbase.ByteBufferKeyValue.getTimestamp(ByteBufferKeyValue.java:135)
	at org.apache.hadoop.hbase.regionserver.TimeRangeTracker.includeTimestamp(TimeRangeTracker.java:81)
	at org.apache.hadoop.hbase.regionserver.Segment.updateMetaInfo(Segment.java:296)
	at org.apache.hadoop.hbase.regionserver.Segment.internalAdd(Segment.java:279)
	at org.apache.hadoop.hbase.regionserver.MutableSegment.add(MutableSegment.java:54)
	at org.apache.hadoop.hbase.regionserver.AbstractMemStore.internalAdd(AbstractMemStore.java:281)
	at org.apache.hadoop.hbase.regionserver.AbstractMemStore.add(AbstractMemStore.java:121)
	at org.apache.hadoop.hbase.regionserver.AbstractMemStore.add(AbstractMemStore.java:101)
	at org.apache.hadoop.hbase.regionserver.HStore.add(HStore.java:701)
	at org.apache.hadoop.hbase.regionserver.HRegion.applyToMemstore(HRegion.java:3952)
	at org.apache.hadoop.hbase.regionserver.HRegion.applyFamilyMapToMemstore(HRegion.java:3935)
	at org.apache.hadoop.hbase.regionserver.HRegion.doMiniBatchMutate(HRegion.java:3392)
	at org.apache.hadoop.hbase.regionserver.HRegion.batchMutate(HRegion.java:3084)
	at org.apache.hadoop.hbase.regionserver.HRegion.batchMutate(HRegion.java:3026)
	at org.apache.hadoop.hbase.regionserver.RSRpcServices.doBatchOp(RSRpcServices.java:906)
	at org.apache.hadoop.hbase.regionserver.RSRpcServices.doNonAtomicRegionMutation(RSRpcServices.java:868)
	at org.apache.hadoop.hbase.regionserver.RSRpcServices.multi(RSRpcServices.java:2456)
	at org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos$ClientService$2.callBlockingMethod(ClientProtos.java:40312)
	at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:1138)
	at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:133)
	at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:277)
	at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:257)
{noformat}

Making BBU#copyFromBufferToBuffer thread-safe is cheaper and easier; In contrast, it may be
inefficient to synchronize the chunk in MSLAB.

> Make ByteBufferUtils thread-safe
> --------------------------------
>
>                 Key: HBASE-17872
>                 URL: https://issues.apache.org/jira/browse/HBASE-17872
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Chia-Ping Tsai
>            Assignee: Chia-Ping Tsai
>            Priority: Critical
>
> A case is shown below.
> We will get the wrong position of buffer in multithreaded environment, so the method
makes the invalid cell in MSLAB.
> {noformat}
>   public static int copyFromBufferToBuffer(ByteBuffer in, ByteBuffer out, int sourceOffset,
>       int destinationOffset, int length) {
>     if (in.hasArray() && out.hasArray()) {
>       // ...
>     } else if (UNSAFE_AVAIL) {
>       // ...
>     } else {
>       int outOldPos = out.position();
>       out.position(destinationOffset);
>       ByteBuffer inDup = in.duplicate();
>       inDup.position(sourceOffset).limit(sourceOffset + length);
>       out.put(inDup);
>       out.position(outOldPos);
>     }
>     return destinationOffset + length;
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message