"allow-nonxdr-writes"って?
表題にある"allow-nonxdr-writes"オプションを試してみます。
マニュアルを見ると以下のように非XDRによる書き込みを禁止できそうです。つまりある特定ノードをReadonly状態にできそうです。デフォルトはtrueで許可しているので書き込みOKなのですが、falseにしてやればよさそう。
Parameter to control the writes done by a non-XDR process. Setting it to false will disallow all the writes from a non-XDR process. This parameter is useful to control accidental writes by a non-XDR process to a namespace when it is not expected.
これで何が幸せになるかと言うと、xdrはプロセスの起動時にデータをこぼすという闇を抱えています。話すと長いので↓この辺参照ください。このオプションで事前にasdへの書き込みを停止できればxdrが転送するデータの取りこぼしもなくなるであろうと期待を抱きました。
※xdrのあれ・・(ん~そんなに書いてなかったか・・)
https://prezi.com/5vczimta5s78/meet-up-to-the-aerospike/
環境作る
まずは3台でクラスタを2つ作り、xdrでレプリケーションさせた状態を作ります。
|クラスタ1| =>(レプリ)=> |クラスタ2|
クライアントから負荷を掛けて100万行追加した状態が以下です。
負荷はこんな感じで↓
[root@aerocl01 benchmarks]pwd
/usr/local/src/aerospike-client-java-3.1.4/benchmarks
[root@aerocl01 benchmarks]# ./run_benchmarks -h xx.xx.x.xx -p 3000 -n test -k 1000000 -l 1 -s 1 -o S:1 -w RU,50 -z 64
正常に100万行追加され、レプリ先にも100万行が追加されてることが分かります。
負荷中にパラメータ変更
先ほどと同じ負荷を掛けて80万件を超えたあたりでパラメータを変更しました。
事前確認
[root@aero101 ~]# asinfo -v "get-config:context=namespace;id=test"
memory-size=4294967296;high-water-disk-pct=50;high-water-memory-pct=60;evict-tenths-pct=5;stop-writes-pct=90;cold-start-evict-ttl=4294967295;repl-factor=2;default-ttl=2592000;max-ttl=0;conflict-resolution-policy=generation;single-bin=false;ldt-enabled=false;ldt-page-size=8192;enable-xdr=true;sets-enable-xdr=true;ns-forward-xdr-writes=false;allow-nonxdr-writes=true;allow-xdr-writes=true;disallow-null-setname=false;total-bytes-memory=4294967296;read-consistency-level-override=off;write-commit-level-override=off;migrate-tx-partitions-initial=139;migrate-tx-partitions-remaining=0;migrate-rx-partitions-initial=2695;migrate-rx-partitions-remaining=0;migrate-tx-partitions-imbalance=0
変更
[root@aero101 ~]# asinfo -v "set-config:context=namespace;id=test;allow-nonxdr-writes=false"
ok
[root@aero101 ~]# asinfo -v "get-config:context=namespace;id=test"
memory-size=4294967296;high-water-disk-pct=50;high-water-memory-pct=60;evict-tenths-pct=5;stop-writes-pct=90;cold-start-evict-ttl=4294967295;repl-factor=2;default-ttl=2592000;max-ttl=0;conflict-resolution-policy=generation;single-bin=false;ldt-enabled=false;ldt-page-size=8192;enable-xdr=true;sets-enable-xdr=true;ns-forward-xdr-writes=false;allow-nonxdr-writes=false;allow-xdr-writes=true;disallow-null-setname=false;total-bytes-memory=4294967296;read-consistency-level-override=off;write-commit-level-override=off;migrate-tx-partitions-initial=0;migrate-tx-partitions-remaining=0;migrate-rx-partitions-initial=2695;migrate-rx-partitions-remaining=0;migrate-tx-partitions-imbalance=0
[root@lab-dev-aero101 ~]# asinfo -v "get-config:context=namespace;id=test" | grep allow
memory-size=4294967296;high-water-disk-pct=50;high-water-memory-pct=60;evict-tenths-pct=5;stop-writes-pct=90;cold-start-evict-ttl=4294967295;repl-factor=2;default-ttl=2592000;max-ttl=0;conflict-resolution-policy=generation;single-bin=false;ldt-enabled=false;ldt-page-size=8192;enable-xdr=true;sets-enable-xdr=true;ns-forward-xdr-writes=false;allow-nonxdr-writes=false;allow-xdr-writes=true;disallow-null-setname=false;total-bytes-memory=4294967296;read-consistency-level-override=off;write-commit-level-override=off;migrate-tx-partitions-initial=0;migrate-tx-partitions-remaining=0;migrate-rx-partitions-initial=2695;migrate-rx-partitions-remaining=0;migrate-tx-partitions-imbalance=0
変更は無事完了
どうだったか
ダメでした。。
図の3つ目のノードに対してパラメータ変えたのですが、見て分かる通り容量増えています(確かに増加率は他より低いのですが)。これはおそらく新規書き込みは来てないのですが、他のノードで書かれたマスタのレプリを作成する書き込みは行われているように見えました。レプリの数が増えていたので。
しかも負荷側からはWriteエラー吐き出した(´・ω・`)
2015-12-28 13:01:44.664 write(tps=8637 timeouts=0 errors=4520) read(tps=12967 timeouts=0 errors=0) total(tps=21604 timeouts=0 errors=4520)
2015-12-28 13:01:45.665 write(tps=8775 timeouts=0 errors=4595) read(tps=13280 timeouts=0 errors=0) total(tps=22055 timeouts=0 errors=4595)
2015-12-28 13:01:46.665 write(tps=9974 timeouts=0 errors=5237) read(tps=15171 timeouts=0 errors=0) total(tps=25145 timeouts=0 errors=5237)
2015-12-28 13:01:47.665 write(tps=7518 timeouts=0 errors=3919) read(tps=11354 timeouts=0 errors=0) total(tps=18872 timeouts=0 errors=3919)
2015-12-28 13:01:48.666 write(tps=9346 timeouts=0 errors=4948) read(tps=14267 timeouts=0 errors=0) total(tps=23613 timeouts=0 errors=4948)
2015-12-28 13:01:49.666 write(tps=9135 timeouts=0 errors=4828) read(tps=13970 timeouts=0 errors=0) total(tps=23105 timeouts=0 errors=4828)
2015-12-28 13:01:50.666 write(tps=7890 timeouts=0 errors=4091) read(tps=11795 timeouts=0 errors=0) total(tps=19685 timeouts=0 errors=4091)
2015-12-28 13:01:51.666 write(tps=8396 timeouts=0 errors=4289) read(tps=12737 timeouts=0 errors=0) total(tps=21133 timeouts=0 errors=4289)
2015-12-28 13:01:52.667 write(tps=9311 timeouts=0 errors=4845) read(tps=14229 timeouts=0 errors=0) total(tps=23540 timeouts=0 errors=4845)
2015-12-28 13:01:53.667 write(tps=9204 timeouts=0 errors=4673) read(tps=13567 timeouts=0 errors=0) total(tps=22771 timeouts=0 errors=4673)
2015-12-28 13:01:54.667 write(tps=8244 timeouts=0 errors=4371) read(tps=12868 timeouts=0 errors=0) total(tps=21112 timeouts=0 errors=4371)
2015-12-28 13:01:55.668 write(tps=9317 timeouts=0 errors=4930) read(tps=14286 timeouts=0 errors=0) total(tps=23603 timeouts=0 errors=4930)
こっちが想定したパラメーターではないかもですが、こちらの期待はもろくも崩ましたw