leo-project / leofs

The LeoFS Storage System
https://leo-project.net/leofs/
Apache License 2.0
1.55k stars 155 forks source link

[bug]The number of queue messages can be wrong value #77

Closed mocchira closed 11 years ago

mocchira commented 11 years ago
yosukehara commented 11 years ago

I'll implement this issue in this week. Thanks.

yosukehara commented 11 years ago

I found a bitcask's problem as the follows:


%% Check key_count: total number is "2"
> leo_backend_db_api:status('test-db').
[[{key_count,0},{status,[]}],
 [{key_count,2},
  {status,[{"/home/yosuke/dev/temp/bitcask-test/1/1.bitcask.data",0,0,52}]}],
 [{key_count,0},
  {status,[{"/home/yosuke/dev/temp/bitcask-test/0/1.bitcask.data",100,78,78}]}]]

%% After shutdown and relaunch, Check "key_count": total number is "5" (not expect value)
1> leo_backend_db_api:new('test-db', 3, bitcask, "/home/yosuke/dev/temp/bitcask-test/").
* bitcask - path:/home/yosuke/dev/temp/bitcask-test/0, handle:#Ref<0.0.0.98>

=ERROR REPORT==== 20-Jun-2013::22:03:34 ===
Hintfile '/home/yosuke/dev/temp/bitcask-test/0/2.bitcask.hint' invalid

=ERROR REPORT==== 20-Jun-2013::22:03:34 ===
Hintfile '/home/yosuke/dev/temp/bitcask-test/0/1.bitcask.hint' invalid
* bitcask - path:/home/yosuke/dev/temp/bitcask-test/1, handle:#Ref<0.0.0.140>

=ERROR REPORT==== 20-Jun-2013::22:03:34 ===
Hintfile '/home/yosuke/dev/temp/bitcask-test/1/1.bitcask.hint' invalid
* bitcask - path:/home/yosuke/dev/temp/bitcask-test/2, handle:#Ref<0.0.0.160>
ok
2> leo_backend_db_api:status('test-db').
[[{key_count,0},{status,[]}],
 [{key_count,2},
  {status,[{"/home/yosuke/dev/temp/bitcask-test/1/1.bitcask.data",
            0,0,52}]}],
 [{key_count,3},
  {status,[{"/home/yosuke/dev/temp/bitcask-test/0/2.bitcask.data",
            0,0,108},
           {"/home/yosuke/dev/temp/bitcask-test/0/1.bitcask.data",100,
            78,78}]}]]

From now, I'm going to consider to resolve this problem.

yosukehara commented 11 years ago

So I found the method of resolution as the follows:

bitcask:merge("/home/yosuke/dev/temp/bitcask-test/0").
ok
15> leo_backend_db_api:status('test-db').
[[{key_count,0},{status,[]}],
 [{key_count,0},{status,[]}],
 [{key_count,0},{status,[]}]]

We need to call bitcask:merge/1 after the storage relaunched.

yosukehara commented 11 years ago

Fixed it. https://github.com/leo-project/leo_backend_db/commit/39061342f51b7dd9122537516242e919795ce76a