bzznectar/nectar

createFileJob needs synchronization

Closed this issue · 1 comments

I was curious about how the disk space consumption is being initialized so I added the following log statement at

for i := 0; i < cpuNUm; i++ {

alog.Info("createFileJob: Increase " + strconv.FormatInt(int64(_id),10) + " to " + strconv.FormatInt(int64(MaxId),10) + " across " + strconv.FormatInt(int64(cpuNUm),10) + "CPUs")

Imagine my surprise to see that the _id doesn't actually go up by one for each invocation of createFileJob. Because there is no locking, and no synchronization between the asynchronously executing go routines, the _id is actually writing a LOT more than is intended.

INFO[2021-12-06T23:20:48-05:00] [createFileJob: Increase 432 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:49-05:00] [createFileJob: Increase 405 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:50-05:00] [createFileJob: Increase 397 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:51-05:00] [createFileJob: Increase 382 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:52-05:00] [createFileJob: Increase 393 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:53-05:00] [createFileJob: Increase 389 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:54-05:00] [createFileJob: Increase 392 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:55-05:00] [createFileJob: Increase 408 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:56-05:00] [createFileJob: Increase 414 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:57-05:00] [createFileJob: Increase 422 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:58-05:00] [createFileJob: Increase 423 to 1201 across 16CPUs]
INFO[2021-12-06T23:20:59-05:00] [createFileJob: Increase 424 to 1201 across 16CPUs]
INFO[2021-12-06T23:21:00-05:00] [createFileJob: Increase 430 to 1201 across 16CPUs]
INFO[2021-12-06T23:21:01-05:00] [createFileJob: Increase 427 to 1201 across 16CPUs]
INFO[2021-12-06T23:21:02-05:00] [createFileJob: Increase 430 to 1201 across 16CPUs]
INFO[2021-12-06T23:21:03-05:00] [createFileJob: Increase 430 to 1201 across 16CPUs]
INFO[2021-12-06T23:21:04-05:00] [createFileJob: Increase 410 to 1201 across 16CPUs]

Please update to the latest version