Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Ints;
import org.apache.druid.error.DruidException;
import org.apache.druid.java.util.common.FileUtils;
import org.apache.druid.java.util.common.IAE;
import org.apache.druid.java.util.common.IOE;
Expand Down Expand Up @@ -158,7 +159,13 @@ public SegmentFileChannel addWithChannel(final String name, final long size) thr
public SmooshedWriter addWithSmooshedWriter(final String name, final long size) throws IOException
{
if (size > maxChunkSize) {
throw new IAE("Asked to add buffers[%,d] larger than configured max[%,d]", size, maxChunkSize);
throw DruidException.forPersona(DruidException.Persona.ADMIN)
.ofCategory(DruidException.Category.RUNTIME_FAILURE)
.build("Serialized buffer size[%,d] for column[%s] exceeds the maximum[%,d]. "
+ "Consider adjusting the tuningConfig - for example, reduce maxRowsPerSegment, "
+ "or partition your data further.",
size, name, maxChunkSize
);
}

// If current writer is in use then create a new SmooshedWriter which
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
import com.google.common.io.Files;
import com.google.common.primitives.Ints;
import junit.framework.Assert;
import org.apache.druid.error.DruidException;
import org.apache.druid.error.DruidExceptionMatcher;
import org.apache.druid.java.util.common.BufferUtils;
import org.apache.druid.java.util.common.ISE;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.segment.file.SegmentFileChannel;
import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand Down Expand Up @@ -80,6 +83,22 @@ public void testWhenFirstWriterClosedInTheMiddle() throws Exception
validateOutput(baseDir);
}

@Test
public void testColumnSerializedSizeExceedsMaximum() throws Exception
{
File baseDir = folder.newFolder("base");
try (FileSmoosher smoosher = new FileSmoosher(baseDir, 5)) {
MatcherAssert.assertThat(
org.junit.Assert.assertThrows(
DruidException.class,
() -> smoosher.addWithChannel("foo", 10)
),
new DruidExceptionMatcher(DruidException.Persona.ADMIN, DruidException.Category.RUNTIME_FAILURE, "general")
.expectMessageContains("Serialized buffer size[10] for column[foo] exceeds the maximum[5].")
);
}
}

@Test(expected = ISE.class)
public void testExceptionForUnClosedFiles() throws Exception
{
Expand Down
Loading