Temporal-History => Help us understand this error! => Task queue range ID was 240 when it was should have been 239

Task queue range ID was 240 when it was should have been 239**

This can be a transient error that can happen during restart/redeploy for example. If so you can ignore it. See similar forum post here.

query directly though matching on non-sticky failed

This error is logged here, could you provide the entire error?
Also can you assure that the task queue used by the query still has worker(s) polling it? If there is, can you see if workers are logging any errors? If there is not, that could be cause of issue (you need workers running to handle the query request).