This document summarizes some lesser known features in Apache Cassandra 2.1, including:
1) Cassandra's logging was changed to use Logback, allowing for faster and more configurable logging through a logback.xml file.
2) New default paths were added in Cassandra 2.1 for data, commit logs, and configurations to keep directories cleaner.
3) A number of command line parameters and YAML configuration options were added for more control over logging levels, commit log handling, compaction settings, and more.
4) Enhancements were made to the CQL shell cqlsh and nodetool for additional debugging and management capabilities.
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Cassandra Summit 2014: Lesser Known Features of Cassandra 2.1
1. #CASSANDRASUMMIT
LESSER KNOWN FEATURES
OF CASSANDRA 2.1
Aaron Morton
@aaronmorton
Co-Founder & Principal Consultant
Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License
2. About The Last Pickle.
!
Work with clients to deliver and improve Apache Cassandra
based solutions.
Apache Cassandra Committer, DataStax MVP, Hector
Maintainer, Apache Usergrid Committer.
Based in New Zealand & USA.
15. Add QueryHandler Interface (CASSANDRA-6659)
-Dcassandra.custom_query_handler_class
!
Provide a custom class that
implements
o.a.c.cql3.QueryHandler.
16. Add QueryHandler Interface (CASSANDRA-6659)
Custom implementation to handle
all CQL3 queries.
!
For example logging, slow query log,
stubbing Cassandra.
29. Commit Log Failure Handling (CASSANDRA-6364)
!
ERROR [PERIODIC-COMMIT-LOG-SYNCER] 2014-… CommitLog.java:350 -
Failed to persist commits to disk. Commit disk failure policy is
stop; terminating thread
!
java.io.IOException: Something broke.
at org.apache.cassandra.db.commitlog.AbstractCommitLogService
$1.run(AbstractCommitLogService.java:123)
at java.lang.Thread.run(Thread.java:744)
30. Add file_cache_size_in_mb setting (CASSANDRA-5661)
!
# Total memory to use for sstable-reading buffers.
# Defaults to
# the smaller of 1/4 of heap or 512MB
# file_cache_size_in_mb: 512
31. Add file_cache_size_in_mb setting (CASSANDRA-5661)
File Readers have a 64 KB
buffer.
Compressed File Readers have
two 64 KB buffers.
34. Improve 2.1 flush defaults (CASSANDRA-7551)
!
# memtable_flush_writers defaults to the smaller of (number of
# disks, number of cores), with a minimum of 2 and a maximum of 8.
#
# If your data directories are backed by SSD, you should increase
# this to the number of cores.
# memtable_flush_writers: 8
35. New concurrent_compactors Defaults (CASSANDRA-7139)
!
# concurrent_compactors defaults to the smaller of (number
# of disks, number of cores), with a minimum of 2 and a
# maximum of 8.
#
# If your data directories are backed by SSD, you should
# increase this to the number of cores.
# concurrent_compactors: 1
36. Throw Error When Frame Too Large (CASSANDRA-5981)
!
# native_transport_max_frame_size_in_mb: 256
!
Improves Existing Behaviour,
InvalidRequestException now
thrown.
40. Drop queries reading many Tombstones (CASSANDRA-6117)
Replaces
tombstone_debug_threshold
41. Drop queries reading many Tombstones (CASSANDRA-6117)
!
tombstone_warn_threshold: 1000
42. Drop queries reading many Tombstones (CASSANDRA-6117)
WARN [main] …
!
SliceQueryFilter.java:236 - Read 2 live and 4
tombstoned cells in system.schema_columnfamilies (see
tombstone_warn_threshold). 2147483631 columns was
requested, slices=[-],
delInfo={deletedAt=-9223372036854775808,
localDeletion=2147483647}
43. Drop query that using Tombstones (CASSANDRA-6117)
!
tombstone_failure_threshold: 100000
44. Drop query that using Tombstones (CASSANDRA-6117)
!
ERROR [SharedPool-Worker-7] …
!
SliceQueryFilter.java:212 - Scanned
over 100000 tombstones in
system.schema_columns; query aborted
(see tombstone_fail_threshold)
45. Log a Warning for Large Batches (CASSANDRA-6487)
!
batch_size_warn_threshold_in_kb: 5
46. Log a Warning for Large Batches (CASSANDRA-6487)
!
WARN [Native-Transport-Requests:553]…
!
BatchStatement.java (line 228) Batch of prepared
statements for
[Keyspace1.Standard1] is of size 6165,
exceeding specified threshold of 5120 by 1045.
47. Preemptive opening compaction result (CASSANDRA-6916)
Replaces
compaction_preheat_key_cache: true,
preheat_kernel_page_cache: false
and
populate_io_cache_on_flush
table property.
58. Pass cqlsh Statements via Command Line CASSANDRA-7172
!
bin/cqlsh --execute="select distinct foo from dev.foo;"
!
foo
-------
three
one
five
two
four
!
(5 rows)
59. Include CQL in Error Messages (CASSANDRA-7111)
!
cqlsh:dev> SELECT foo bar from foo;
!
<ErrorMessage code=2000 [Syntax error in CQL query]
message="line 1:11 no viable alternative at input 'bar'">
cqlsh:dev>
!
61. Set & Get Logging Levels via nodetool (CASSANDRA-7090)
!
nodetool getlogginglevels
Logger Name Log Level
ROOT INFO
com.thinkaurelius.thrift ERROR
!
nodetool setlogginglevel org.apache.cassandra.db.Row DEBUG
!
nodetool getlogginglevels
Logger Name Log Level
ROOT INFO
com.thinkaurelius.thrift ERROR
org.apache.cassandra.db.Row DEBUG
62. Add listsnapshots To nodetool (CASSANDRA-5742)
!
nodetool listsnapshots
!
Snapshot Details:
Snapshot name Keyspace name Column family True size Size on disk
pre-migration Keyspace1 Standard1 508.03 MB 555.59 MB
all-good Keyspace1 Standard1 549.01 MB 803.68 MB
!
Total TrueDiskSpaceUsed: 1.03 GB
63. Add Snapshot Space Used To cfstats (CASSANDRA-6231)
!
Table: Standard1
SSTable count: 4
Space used (live), bytes: 76875505
Space used (total), bytes: 76875505
Space used by snapshots (total), bytes: 1108391939
64. Save Compaction History (CASSANDRA-5078)
!
nodetool compactionhistory
!
id keyspace columnfamily compacted_at bytes_in bytes_out
31...9d Keyspace1 Standard1 1410287780455 488451903 174360500
51...9d Keyspace1 Standard1 1410287834272 527847260 256812363
65. Repairing Between Specific Replicas (CASSANDRA-6440)
!
nodetool repair
[(-dc <specific_dc> | --in-dc <specific_dc>)...]
[(-hosts <specific_host> | --in-hosts <specific_host>)]
66. Reset SSTable LCS Compaction Level (CASSANDRA-5271)
!
sstablelevelreset --really-reset Keyspace1 Standard1
!
!
Changing level from 1 to 0 on …/Keyspace1-Standard1-ka-35-Data.db
!
Skipped .../Keyspace1-Standard1-ka-33-Data.db since it is already
on level 0
!
Changing level from 1 to 0 on …/Keyspace1-Standard1-ka-32-Data.db
!
Skipped .../Keyspace1-Standard1-ka-34-Data.db since it is already
on level 0
!
79. Track min/max Clustered Values (CASSANDRA-5514)
!
SELECT
event_time, temperature
FROM
temperature
WHERE
weatherstation_id='1234ABCD'
AND
event_time >= '2013-04-03 07:01:00'
AND
event_time <= '2013-04-03 07:04:00';
80. Track min/max Clustered Values (CASSANDRA-5514)
Skips SSTables that will not
contain relevant data.
81. The Take Away
Use Cassandra v2.0.10
!
Get testing on v2.1.0