Serialization seems to fail for query param `serial_consistency`
gowthamk opened this issue · comments
serial_consistency
is one of the query params whose default value is set to None
in src/scylla.ml
. I added consistency
and serial_consistency
as optional arguments to Scylla.query
in my fork so that non-default values can be passed. Unfortunately, query serialization seems to fail when I pass Scylla.Protocol.Serial
as value for serial_consistency
query param. This param is necessary for Scylla's conditional writes (lightweight transactions).
The following script reproduces the error:
(*
* Assumes scylla is running on localhost at 9042 port.
*
* Before you run this script, set up the db as following:
* create keyspace if not exists keyspace1 with replication={'class':'SimpleStrategy', 'replication_factor':3}
* create table if not exists keyspace1.employee(id int primary key, name text)
* insert into keyspace1.employee(id,name) VALUES(1, 'anderson')
*)
let conn = Scylla.connect ~ip:"127.0.0.1" ~port:9042 |> Result.get_ok
let () = Printf.printf "Opened connection.\n"
let keyspace = "keyspace1"
let table = "employee"
let update_query = Printf.sprintf
"update %s.%s set name = ? where id = ? if name = ?"
keyspace table
let big_of_string s = Bigstringaf.of_string s ~off:0 ~len:(String.length s);;
let res = Scylla.query conn
~query:update_query
~values:[| Scylla.Protocol.Varchar (big_of_string "smith");
Scylla.Protocol.Int 1l;
Scylla.Protocol.Varchar (big_of_string "anderson")
|]
~consistency: Scylla.Protocol.One
~serial_consistency: Scylla.Protocol.Serial () in
begin
match res with
| Ok _ -> Ok ()
| Error s -> failwith s
end
Here is the dune file you need to compile:
(executable
(name scylla_test)
(libraries scylla))
The error we get is as follows:
error code 10
error msg truncated frame: expected 2 bytes, length is 0
Fatal error: exception Failure("query did not succeed")
Any idea what's going on?
I have pushed some changes, which should fix the issue. Let me know if it works for you.
The fix works. Thanks!