This is an automated email from the ASF dual-hosted git repository. brandonwilliams pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 5c3eb26c76a5ba176fb9f8421e361a8f8b572959 Merge: 1266fec 29f53fe Author: Brandon Williams <brandonwilli...@apache.org> AuthorDate: Wed Jul 22 12:31:29 2020 -0500 Merge branch 'cassandra-3.11' into trunk CHANGES.txt | 2 + .../apache/cassandra/db/marshal/AbstractType.java | 10 +- .../apache/cassandra/db/marshal/DecimalType.java | 7 +- .../apache/cassandra/db/marshal/DoubleType.java | 2 + .../org/apache/cassandra/db/marshal/FloatType.java | 2 + .../cassandra/db/marshal/InetAddressType.java | 7 +- .../org/apache/cassandra/db/marshal/Int32Type.java | 3 +- .../apache/cassandra/db/marshal/IntegerType.java | 3 +- .../org/apache/cassandra/db/marshal/LongType.java | 3 +- .../org/apache/cassandra/db/marshal/ShortType.java | 3 +- .../apache/cassandra/db/marshal/TimestampType.java | 7 +- .../org/apache/cassandra/cql3/EmptyValuesTest.java | 240 +++++++++++++++++++++ .../apache/cassandra/db/marshal/UUIDTypeTest.java | 8 + 13 files changed, 286 insertions(+), 11 deletions(-) diff --cc CHANGES.txt index 90d0129,028b0ff..399b263 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,69 -1,10 +1,71 @@@ -3.11.8 +4.0-beta2 + * Optimize NoSpamLogger use in hot paths (CASSANDRA-15766) + * Verify sstable components on startup (CASSANDRA-15945) +Merged from 3.11: * Frozen RawTuple is not annotated with frozen in the toString method (CASSANDRA-15857) + Merged from 3.0: + * Fix empty/null json string representation (CASSANDRA-15896) -3.11.7 +4.0-beta1 + * Remove BackPressureStrategy (CASSANDRA-15375) + * Improve messaging on indexing frozen collections (CASSANDRA-15908) + * USING_G1 is incorrectly set in cassandra-env.sh if G1 is explicitly disabled with -UseG1GC (CASSANDRA-15931) + * Update compaction_throughput_mb_per_sec throttle default to 64 (CASSANDRA-14902) + * Add option to disable compaction at startup (CASSANDRA-15927) + * FBUtilities.getJustLocalAddress falls back to lo ip on misconfigured nodes (CASSANDRA-15901) + * Close channel and reduce buffer allocation during entire sstable streaming with SSL (CASSANDRA-15900) + * Prune expired messages less frequently in internode messaging (CASSANDRA-15700) + * Fix Ec2Snitch handling of legacy mode for dc names matching both formats, eg "us-west-2" (CASSANDRA-15878) + * Add support for server side DESCRIBE statements (CASSANDRA-14825) + * Fail startup if -Xmn is set when the G1 garbage collector is used (CASSANDRA-15839) + * generateSplits method replaced the generateRandomTokens for ReplicationAwareTokenAllocator. (CASSANDRA-15877) + * Several mbeans are not unregistered when dropping a keyspace and table (CASSANDRA-14888) + * Update defaults for server and client TLS settings (CASSANDRA-15262) + * Differentiate follower/initator in StreamMessageHeader (CASSANDRA-15665) + * Add a startup check to detect if LZ4 uses java rather than native implementation (CASSANDRA-15884) + * Fix missing topology events when running multiple nodes on the same network interface (CASSANDRA-15677) + * Create config.yml.MIDRES (CASSANDRA-15712) + * Fix handling of fully purged static rows in repaired data tracking (CASSANDRA-15848) + * Prevent validation request submission from blocking ANTI_ENTROPY stage (CASSANDRA-15812) + * Add fqltool and auditlogviewer to rpm and deb packages (CASSANDRA-14712) + * Include DROPPED_COLUMNS in schema digest computation (CASSANDRA-15843) + * Fix Cassandra restart from rpm install (CASSANDRA-15830) + * Improve handling of 2i initialization failures (CASSANDRA-13606) + * Add completion_ratio column to sstable_tasks virtual table (CASANDRA-15759) + * Add support for adding custom Verbs (CASSANDRA-15725) + * Speed up entire-file-streaming file containment check and allow entire-file-streaming for all compaction strategies (CASSANDRA-15657,CASSANDRA-15783) + * Provide ability to configure IAuditLogger (CASSANDRA-15748) + * Fix nodetool enablefullquerylog blocking param parsing (CASSANDRA-15819) + * Add isTransient to SSTableMetadataView (CASSANDRA-15806) + * Fix tools/bin/fqltool for all shells (CASSANDRA-15820) + * Fix clearing of legacy size_estimates (CASSANDRA-15776) + * Update port when reconnecting to pre-4.0 SSL storage (CASSANDRA-15727) + * Only calculate dynamicBadnessThreshold once per loop in DynamicEndpointSnitch (CASSANDRA-15798) + * Cleanup redundant nodetool commands added in 4.0 (CASSANDRA-15256) + * Update to Python driver 3.23 for cqlsh (CASSANDRA-15793) + * Add tunable initial size and growth factor to RangeTombstoneList (CASSANDRA-15763) + * Improve debug logging in SSTableReader for index summary (CASSANDRA-15755) + * bin/sstableverify should support user provided token ranges (CASSANDRA-15753) + * Improve logging when mutation passed to commit log is too large (CASSANDRA-14781) + * replace LZ4FastDecompressor with LZ4SafeDecompressor (CASSANDRA-15560) + * Fix buffer pool NPE with concurrent release due to in-progress tiny pool eviction (CASSANDRA-15726) + * Avoid race condition when completing stream sessions (CASSANDRA-15666) + * Flush with fast compressors by default (CASSANDRA-15379) + * Fix CqlInputFormat regression from the switch to system.size_estimates (CASSANDRA-15637) + * Allow sending Entire SSTables over SSL (CASSANDRA-15740) + * Fix CQLSH UTF-8 encoding issue for Python 2/3 compatibility (CASSANDRA-15739) + * Fix batch statement preparation when multiple tables and parameters are used (CASSANDRA-15730) + * Fix regression with traceOutgoingMessage printing message size (CASSANDRA-15687) + * Ensure repaired data tracking reads a consistent amount of data across replicas (CASSANDRA-15601) + * Fix CQLSH to avoid arguments being evaluated (CASSANDRA-15660) + * Correct Visibility and Improve Safety of Methods in LatencyMetrics (CASSANDRA-15597) + * Allow cqlsh to run with Python2.7/Python3.6+ (CASSANDRA-15659,CASSANDRA-15573) + * Improve logging around incremental repair (CASSANDRA-15599) + * Do not check cdc_raw_directory filesystem space if CDC disabled (CASSANDRA-15688) + * Replace array iterators with get by index (CASSANDRA-15394) + * Minimize BTree iterator allocations (CASSANDRA-15389) +Merged from 3.11: * Fix cqlsh output when fetching all rows in batch mode (CASSANDRA-15905) * Upgrade Jackson to 2.9.10 (CASSANDRA-15867) * Fix CQL formatting of read command restrictions for slow query log (CASSANDRA-15503) diff --cc src/java/org/apache/cassandra/db/marshal/DecimalType.java index 110dc0e,05ac2e2..dd47ded --- a/src/java/org/apache/cassandra/db/marshal/DecimalType.java +++ b/src/java/org/apache/cassandra/db/marshal/DecimalType.java @@@ -18,10 -18,8 +18,11 @@@ package org.apache.cassandra.db.marshal; import java.math.BigDecimal; +import java.math.BigInteger; +import java.math.MathContext; +import java.math.RoundingMode; import java.nio.ByteBuffer; + import java.util.Objects; import org.apache.cassandra.cql3.CQL3Type; import org.apache.cassandra.cql3.Constants; diff --cc src/java/org/apache/cassandra/db/marshal/IntegerType.java index e2b8518,beb6759..044fe6e --- a/src/java/org/apache/cassandra/db/marshal/IntegerType.java +++ b/src/java/org/apache/cassandra/db/marshal/IntegerType.java @@@ -17,9 -17,9 +17,10 @@@ */ package org.apache.cassandra.db.marshal; +import java.math.BigDecimal; import java.math.BigInteger; import java.nio.ByteBuffer; + import java.util.Objects; import org.apache.cassandra.cql3.CQL3Type; import org.apache.cassandra.cql3.Constants; diff --cc test/unit/org/apache/cassandra/cql3/EmptyValuesTest.java index 0000000,6c42a59..3652ac8 mode 000000,100644..100644 --- a/test/unit/org/apache/cassandra/cql3/EmptyValuesTest.java +++ b/test/unit/org/apache/cassandra/cql3/EmptyValuesTest.java @@@ -1,0 -1,240 +1,240 @@@ + /* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package org.apache.cassandra.cql3; + + import java.io.ByteArrayOutputStream; + import java.io.PrintStream; + import java.nio.charset.StandardCharsets; + import java.util.regex.Pattern; + + import org.apache.commons.io.IOUtils; + + import org.junit.Assert; + import org.junit.Test; + + import com.datastax.driver.core.ResultSet; + import com.datastax.driver.core.Row; + import org.apache.cassandra.db.ColumnFamilyStore; + import org.apache.cassandra.db.marshal.BytesType; + import org.apache.cassandra.db.marshal.DecimalType; + import org.apache.cassandra.db.marshal.DoubleType; + import org.apache.cassandra.db.marshal.FloatType; + import org.apache.cassandra.db.marshal.InetAddressType; + import org.apache.cassandra.db.marshal.Int32Type; + import org.apache.cassandra.db.marshal.LongType; + import org.apache.cassandra.db.marshal.ShortType; + import org.apache.cassandra.db.marshal.SimpleDateType; + import org.apache.cassandra.db.marshal.TimeType; + import org.apache.cassandra.db.marshal.TimeUUIDType; + import org.apache.cassandra.db.marshal.TimestampType; + import org.apache.cassandra.db.marshal.UTF8Type; + import org.apache.cassandra.db.marshal.UUIDType; + import org.apache.cassandra.io.sstable.format.SSTableReader; -import org.apache.cassandra.transport.Server; ++import org.apache.cassandra.transport.ProtocolVersion; + import org.apache.cassandra.utils.ByteBufferUtil; + + import static org.junit.Assume.assumeTrue; + + public class EmptyValuesTest extends CQLTester + { + private void verify(String emptyValue) throws Throwable + { + UntypedResultSet result = execute("SELECT * FROM %s"); + UntypedResultSet.Row row = result.one(); + Assert.assertTrue(row.getColumns().stream().anyMatch(c -> c.name.toString().equals("v"))); + Assert.assertEquals(0, row.getBytes("v").remaining()); + - ResultSet resultNet = executeNet(Server.CURRENT_VERSION, "SELECT * FROM %s"); ++ ResultSet resultNet = executeNet(ProtocolVersion.CURRENT, "SELECT * FROM %s"); + Row rowNet = resultNet.one(); + Assert.assertTrue(rowNet.getColumnDefinitions().contains("v")); + Assert.assertEquals(0, rowNet.getBytesUnsafe("v").remaining()); + - ResultSet jsonNet = executeNet(Server.CURRENT_VERSION, "SELECT JSON * FROM %s"); ++ ResultSet jsonNet = executeNet(ProtocolVersion.CURRENT, "SELECT JSON * FROM %s"); + Row jsonRowNet = jsonNet.one(); + Assert.assertTrue(jsonRowNet.getString("[json]"), jsonRowNet.getString("[json]").matches(".*\"v\"\\s*:\\s*\"" + Pattern.quote(emptyValue) + "\".*")); + + ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); + ByteArrayOutputStream buf = new ByteArrayOutputStream(); + for (SSTableReader ssTable : cfs.getLiveSSTables()) + { + try (PrintStream out = new PrintStream(buf, true)) + { + ProcessBuilder pb = new ProcessBuilder("tools/bin/sstabledump", ssTable.getFilename()); + Process process = pb.start(); + process.waitFor(); + IOUtils.copy(process.getInputStream(), buf); + } + catch (Throwable t) + { + Assert.fail(t.getClass().getName()); + } + } + + String outString = new String(buf.toByteArray(), StandardCharsets.UTF_8); + Assert.assertTrue(outString, outString.contains("{ \"name\" : \"v\", \"value\" : \"" + emptyValue + "\" }")); + } + + private void verifyPlainInsert(String emptyValue) throws Throwable + { + execute("TRUNCATE %s"); + + // In most cases we cannot insert empty value when we do not bind variables + // This is due to the current implementation of org.apache.cassandra.cql3.Constants.Literal.testAssignment + // execute("INSERT INTO %s (id, v) VALUES (1, '" + emptyValue + "')"); + execute("INSERT INTO %s (id, v) VALUES (1, ?)", ByteBufferUtil.EMPTY_BYTE_BUFFER); + flush(); + + verify(emptyValue); + } + + private void verifyJsonInsert(String emptyValue) throws Throwable + { + execute("TRUNCATE %s"); + execute("INSERT INTO %s JSON '{\"id\":\"1\",\"v\":\"" + emptyValue + "\"}'"); + flush(); + + verify(emptyValue); + } + + @Test + public void testEmptyInt() throws Throwable + { + assumeTrue(Int32Type.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v INT)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyText() throws Throwable + { + assumeTrue(UTF8Type.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v TEXT)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyTimestamp() throws Throwable + { + assumeTrue(TimestampType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v TIMESTAMP)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyUUID() throws Throwable + { + assumeTrue(UUIDType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v UUID)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyInetAddress() throws Throwable + { + assumeTrue(InetAddressType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v INET)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyLong() throws Throwable + { + assumeTrue(LongType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v BIGINT)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyBytes() throws Throwable + { + assumeTrue(BytesType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v BLOB)"); + verifyJsonInsert("0x"); + verifyPlainInsert(""); + } + + @Test + public void testEmptyDate() throws Throwable + { + assumeTrue(SimpleDateType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v DATE)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyDecimal() throws Throwable + { + assumeTrue(DecimalType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v DECIMAL)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyDouble() throws Throwable + { + assumeTrue(DoubleType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v DOUBLE)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyFloat() throws Throwable + { + assumeTrue(FloatType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v FLOAT)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptySmallInt() throws Throwable + { + assumeTrue(ShortType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v SMALLINT)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyTime() throws Throwable + { + assumeTrue(TimeType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v TIME)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + + @Test + public void testEmptyTimeUUID() throws Throwable + { + assumeTrue(TimeUUIDType.instance.isEmptyValueMeaningless()); + String table = createTable("CREATE TABLE %s (id INT PRIMARY KEY, v TIMEUUID)"); + verifyJsonInsert(""); + verifyPlainInsert(""); + } + } diff --cc test/unit/org/apache/cassandra/db/marshal/UUIDTypeTest.java index 12a8871,74e5ef3..e82f3f5 --- a/test/unit/org/apache/cassandra/db/marshal/UUIDTypeTest.java +++ b/test/unit/org/apache/cassandra/db/marshal/UUIDTypeTest.java @@@ -30,7 -30,8 +30,8 @@@ import java.util.UUID import org.junit.Test; -import junit.framework.Assert; -import org.apache.cassandra.transport.Server; +import org.junit.Assert; ++import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.UUIDGen; import org.slf4j.Logger; @@@ -43,6 -44,13 +44,13 @@@ public class UUIDTypeTes UUIDType uuidType = new UUIDType(); + @Test //CASSANDRA-15896 + public void testToJsonEmptyValue() + { - String res = uuidType.toJSONString(uuidType.fromJSONObject("").bindAndGet(null), Server.CURRENT_VERSION); ++ String res = uuidType.toJSONString(uuidType.fromJSONObject("").bindAndGet(null), ProtocolVersion.CURRENT); + assertEquals("\"\"", res); + } + @Test public void testRandomCompare() { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org