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:
Aliaksandr Valialkin 2021-04-27 16:41:22 +03:00
parent 2d1d60118d
commit e37e1b1e34
2 changed files with 6 additions and 6 deletions

View file

@ -126,7 +126,7 @@ type Table struct {
}
type rawItemsShards struct {
shardIdx uint64
shardIdx uint32
// shards reduce lock contention when adding rows on multi-CPU systems.
shards []rawItemsShard
@ -144,9 +144,9 @@ func (riss *rawItemsShards) init() {
}
func (riss *rawItemsShards) addItems(tb *Table, items [][]byte) error {
n := atomic.AddUint64(&riss.shardIdx, 1)
n := atomic.AddUint32(&riss.shardIdx, 1)
shards := riss.shards
idx := n % uint64(len(shards))
idx := n % uint32(len(shards))
shard := &shards[idx]
return shard.addItems(tb, items)
}

View file

@ -437,7 +437,7 @@ func (pt *partition) AddRows(rows []rawRow) {
}
type rawRowsShards struct {
shardIdx uint64
shardIdx uint32
// Shards reduce lock contention when adding rows on multi-CPU systems.
shards []rawRowsShard
@ -448,9 +448,9 @@ func (rrss *rawRowsShards) init() {
}
func (rrss *rawRowsShards) addRows(pt *partition, rows []rawRow) {
n := atomic.AddUint64(&rrss.shardIdx, 1)
n := atomic.AddUint32(&rrss.shardIdx, 1)
shards := rrss.shards
idx := n % uint64(len(shards))
idx := n % uint32(len(shards))
shard := &shards[idx]
shard.addRows(pt, rows)
}