mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/{storage,mergeset}: fix unaligned 64-bit atomic operation
panic for 32-bit architectures
The panic has been introduced in 56b6b893ce
This commit is contained in:
parent
56b6b893ce
commit
87179c6839
2 changed files with 6 additions and 6 deletions
|
@ -126,7 +126,7 @@ type Table struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type rawItemsShards struct {
|
type rawItemsShards struct {
|
||||||
shardIdx uint64
|
shardIdx uint32
|
||||||
|
|
||||||
// shards reduce lock contention when adding rows on multi-CPU systems.
|
// shards reduce lock contention when adding rows on multi-CPU systems.
|
||||||
shards []rawItemsShard
|
shards []rawItemsShard
|
||||||
|
@ -144,9 +144,9 @@ func (riss *rawItemsShards) init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (riss *rawItemsShards) addItems(tb *Table, items [][]byte) error {
|
func (riss *rawItemsShards) addItems(tb *Table, items [][]byte) error {
|
||||||
n := atomic.AddUint64(&riss.shardIdx, 1)
|
n := atomic.AddUint32(&riss.shardIdx, 1)
|
||||||
shards := riss.shards
|
shards := riss.shards
|
||||||
idx := n % uint64(len(shards))
|
idx := n % uint32(len(shards))
|
||||||
shard := &shards[idx]
|
shard := &shards[idx]
|
||||||
return shard.addItems(tb, items)
|
return shard.addItems(tb, items)
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,7 +437,7 @@ func (pt *partition) AddRows(rows []rawRow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type rawRowsShards struct {
|
type rawRowsShards struct {
|
||||||
shardIdx uint64
|
shardIdx uint32
|
||||||
|
|
||||||
// Shards reduce lock contention when adding rows on multi-CPU systems.
|
// Shards reduce lock contention when adding rows on multi-CPU systems.
|
||||||
shards []rawRowsShard
|
shards []rawRowsShard
|
||||||
|
@ -448,9 +448,9 @@ func (rrss *rawRowsShards) init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rrss *rawRowsShards) addRows(pt *partition, rows []rawRow) {
|
func (rrss *rawRowsShards) addRows(pt *partition, rows []rawRow) {
|
||||||
n := atomic.AddUint64(&rrss.shardIdx, 1)
|
n := atomic.AddUint32(&rrss.shardIdx, 1)
|
||||||
shards := rrss.shards
|
shards := rrss.shards
|
||||||
idx := n % uint64(len(shards))
|
idx := n % uint32(len(shards))
|
||||||
shard := &shards[idx]
|
shard := &shards[idx]
|
||||||
shard.addRows(pt, rows)
|
shard.addRows(pt, rows)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue