How to troubleshoot Tag History not returning any historical data

I have a set of tags that are taking values every second.
I have set up a history provider to store my tag values history in my database.
I can see data is being stored in database table

sql_data_{partition_number}_{year}_{month}

paritions without problem.

The problem is when i query a tag using:

tagPath = "[default]{folder}/{tag_name}"
system.tag.queryTagHistory([tagPath], returnSize = 0)

or

ts_now = system.date.now()
ts_start = system.date.addMinutes(ts_now, -10)
tagPath = "[default]{folder}/{tag_name}"
system.tag.queryTagHistory([tagPath], startDate = ts_start, endDate = ts_now)

I get empty results. tags that I try to query all have

HistroyEnabled = True
HistroyProvider = postgresql (this is my history provider's name)

What do I check to see what is wrong? How do I troubleshoot the history module? How do I make sure it is reliable? Since I am developing logic based on historical data for my alarming system and it has to be reliable.

In the two system.tag.queryTagHistory() code samples you have shown above you haven't assigned the results to a variable.
Can you show your real code?

Here is the code i am running on a button and text area to test the logic:

tagPath = "[Default]_wrfm_/Delete Me"
	
result  = system.tag.queryTagHistory([tagPath], returnSize = 0)
	
self.getSibling("TextArea").props.text = result

the tag i referenced here is an OPC tag.
the result is an empty array.

You haven't provided a time range in that sample code.

It does not have to. with

returnSize = 0

the queryTagHistory function used to fetch all the historical data for the tags fine. but it stopped working and i have checked everything and do not understand why now.

To your point I have checked (startDate, endDate) pair, (startDate, rangeMinutes/rangeHours) pair, and returnSize = 0 with or without range and startDate:

tagPath = "[Default]_wrfm_/Delete Me"
ts_now = system.date.now()
ts_start = system.date.addMinutes(ts_now, -1500)
result  = system.tag.queryTagHistory([tagPath], returnSize = 0, startDate = ts_start, endDate = ts_now)
self.getSibling("TextArea").props.text = result

Nothing works.

Anything special about your gateway (or gateways) setup? Multiple gateways?

I have two gateways but on two different machines in the same network, one for test and one for the main project. The only thing that comes to my mind is that because I had to duplicate the test gateway (by cloning the second machine entire OS image) and then changed the gateway name. It warned me of some malfunctions when I was changing the name of the gateway.

I should also mention that the database is shared on a third machine between these two gateways.

could that be the problem? if so, how can I check/troubleshoot it?

Are you sure there is actually data for the tag you are looking for across the time span you are giving?