[Tarantool-patches] [PATCH v3 2/3] cfg: support symbolic evaluation of replication_synchro_quorum

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Dec 8 00:25:43 MSK 2020


Hi!

> 6.
> tarantool> box.cfg{replication_synchro_quorum='"1"'}
> 2020-12-05 00:49:02.251 [59985] main/103/interactive I> set 'replication_synchro_quorum' configuration option to "\"1\""
> ---
> ...
> 
> I gave string "1", but it is accepted. Can it be fixed?
> 
> Why don't I see this log line "update replication_synchro_quorum",
> which you use in the test in the next commit?

You asked, how to check if the expression is not a number.
This diff works on the example above - raises an error.

====================
@@ -577,7 +577,11 @@ eval_replication_synchro_quorum(int nr_replicas)
 			"sqrt = math.sqrt,"
 			"fmod = math.fmod,"
 		"}})\n"
-		"return math.floor(f())\n";
+		"local res = f()\n"
+		"if type(res) ~= 'number' then\n"
+			"error('Expression should return a number')\n"
+		"end\n"
+		"return math.floor(res)\n";
 	char buf[1024];
 	int value = -1;


More information about the Tarantool-patches mailing list