在 Cassandra 日志中执行 LOG BATCH 警告



我们的 Java 应用程序对 1 个表进行批量插入,该表架构类似于..

CREATE TABLE "My_KeySpace"."my_table" (
    key text,
    column1 varint,
    column2 bigint,
    column3 text,
    column4 boolean,
    value blob,
    PRIMARY KEY (key, column1, column2, column3, column4)
) WITH CLUSTERING ORDER BY ( column1 DESC, column2 DESC, column3 ASC, column4 ASC )
AND COMPACT STORAGE
AND bloom_filter_fp_chance = 0.1
AND comment = ''
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.0
AND default_time_to_live = 0
AND gc_grace_seconds = 0
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.1
AND speculative_retry = 'NONE'
AND caching = {
    'keys' : 'ALL',
    'rows_per_partition' : 'NONE'
}
AND compression = {
    'chunk_length_in_kb' : 64,
    'class' : 'LZ4Compressor',
    'enabled' : true
}
AND compaction = {
    'class' : 'LeveledCompactionStrategy',
    'sstable_size_in_mb' : 5
};

gc_grace_seconds = 0 在上面的架构中。因此,我收到以下警告:

2019-02-05 01:59:53.087 WARN   [SharedPool-Worker-5 - org.apache.cassandra.cql3.statements.BatchStatement:97] Executing a LOGGED BATCH on table [My_KeySpace.my_table], configured with a gc_grace_seconds of 0. The gc_grace_seconds is used to TTL batchlog entries, so setting gc_grace_seconds too low on tables involved in an atomic batch might cause batchlog entries to expire before being replayed.

我看过Cassandra代码,这个警告是有明显原因的:这一行

任何解决方案而不更改应用程序中的批处理代码?我应该增加gc_grace_seconds吗?

在 Cassandra 中,批处理不是优化插入数据库的方法 - 它们通常用于协调写入多个表等。 如果您使用批处理插入到多个分区中,则性能甚至会变差。

通过使用异步命令执行(通过 executeAsync (和/或使用批处理(但仅适用于针对同一分区的插入(,可以获得更好的插入吞吐量。

最新更新