Handle empty non-final pages in ReactiveResultSetSubscription
Description
I tried to use this driver with scylladb database, because it supports CQL protocol. But code started to hang for some queries:
The reason is that scylladb sometime returns a page with no data but with pagingState != null and it leads to code hanging
For instance, if `pages` queue contains three pages:
first page with data and with pagingState != null
second page without data and pagingState != null
third page without data and pagingState = null
Akka stream calls request(1) if it needs data and request calls drain that sends one row to akka stream subscriber. It works well for pages with data. But if there is page without data and `pagingState` != null the following situation appears:
Akka stream calls requests(1) that calls drain that calls tryNext. tryNext method detects that there is no data anymore in page 1 and it gets second page from pages queue. But because of second page has no data, tryNext() will return null and no data will be sent to akka stream subscriber. Because no data will be sent to akka subscriber, akka stream will not call request(1) anymore and drain will not be called from anywhere because all pages are already loaded.
I don't know why scylladb returns pages without data and `pagingState` != null. I will ask scylladb team, but it also would be good to fix this case in driver as well
I tried to use this driver with scylladb database, because it supports CQL protocol. But code started to hang for some queries:
The reason is that scylladb sometime returns a page with no data but with pagingState != null and it leads to code hanging
For instance, if `pages` queue contains three pages:
first page with data and with
pagingState
!= nullsecond page without data and
pagingState
!= nullthird page without data and
pagingState
= nullAkka stream calls
request(1)
if it needs data andrequest
callsdrain
that sends one row to akka stream subscriber. It works well for pages with data. But if there is page without data and `pagingState` != null the following situation appears:Akka stream calls
requests(1)
that callsdrain
that callstryNext
.tryNext
method detects that there is no data anymore in page1
and it gets second page frompages
queue. But because of second page has no data, tryNext() will returnnull
and no data will be sent to akka stream subscriber. Because no data will be sent to akka subscriber, akka stream will not callrequest(1)
anymore anddrain
will not be called from anywhere because all pages are already loaded.I don't know why scylladb returns pages without data and `pagingState` != null. I will ask scylladb team, but it also would be good to fix this case in driver as well