I am trying to build a cursor based pagination API on top of a spanner dataset. To do this I'm am using the read timestamp from the initial request to retrieve data and then encoding this into a cursor which can then be used to do an "Exact staleness" (https://cloud.google.com/spanner/docs/timestamp-bounds) read in subsequent paging requests.
For example, the processing of a request for the first page looks something like:
Transaction tx = spanner.singleUseReadOnlyTransaction();
tx.executeQuery(statement); // result set containing the first page of data
tx.getReadTimestamp(); // read timestamp that gets returned in a cursor
And for subsequent requests:
Transaction tx = spanner.singleUseReadOnlyTransaction(TimestampBound.ofReadTimestamp(cursorTs));
I'd also like to return a message to the user when the cursor timestamp has expired (the documentation linked to above states they are valid for roughly an hour) and to do this I have the following code:
try {
// process spanner result set
} catch (SpannerException e) {
if (ErrorCode.FAILED_PRECONDITION.equals(e.getErrorCode)) {
// cursor has expired, return appropriate error message
}
}
This works fine when manually testing against a long running spanner database. However, in my test code I create a spanner database and then tear it down once the test is complete and in these tests the spanner exception is only thrown intermittently when I use a read timestamp that should definitely be expired (say over a year old). In the cases where no exception is thrown, I get an empty resultset. If I make multiple requests to spanner in my test with this expired read timestamp, eventually the database seems to consistently throw the "failed precondition" error.
Is this behaviour expected for a newly provisioned spanner database?
I believe the reason for this behavior is because you are using Read-only Transactions. As explained in the documentation, Read-only transactions always observe a consistent state of the database and the transaction commit history at a chosen point. In your case, the database is created and torn down before and after your test is completed. Hence, no transaction commit history to be observed except after a number of attempts.
Related
I am using NSUbiquitousKeyValueStore to store user preferences in iCloud. To ensure that I understand how NSUbiquitousKeyValueStore works, I successfully stored a String value and monitored the value on a separate device. The following explains my configuration.
I started by observing the Notification that is posted when the NSUbiquitousKeyValueStore changes externally:
NSUbiquitousKeyValueStore.didChangeExternallyNotification
Then, I set a String value that was input of a UITextField:
let store = NSUbiquitousKeyValueStore.default
store.set(text, forKey: key)
store.synchronize()
To ensure that this works, I created a UIAlertController in the method that responds to the notification. I observed the alert appear on the secondary device within six seconds of setting the value on the primary device. However, I never observed the alert appear on the primary device after setting the value.
After reading the documentation for NSUbiquitousKeyValueStore, I was unable to find a reason that the primary device would not also receive the notification after updating the NSUbiquitousKeyValueStore.
Do I need a solution to save the updated values locally before setting them in the NSUbiquitousKeyValueStore? I can persist the values locally in UserDefaults before persisting them in NSUbiquitousKeyValueStore. However, it would require me to revert the values in UserDefaults if an error should occur during the attempt to persist them in the NSUbiquitousKeyValueStore. Without the primary device being notified of the changes that are persisted from it, will I even be notified of the error in the observation of the notification? I struggle to believe that I will if I am not receiving notifications when successful.
Is there something that I am missing, or is this the expected behavior?
Perhaps they updated the documentation (+ 1 yr since you asked).
"This notification is sent only upon a change received from iCloud; it is not sent when your app sets a value."
I assume that means that because no change is observed (the local device and iCloud are already in sync) - you don't get a notification.
I would like to get some data from a chaincode transaction (too complex for a query), but, as I see from the code, transactions return promises that don't resolve to values. In addition, chaincode has access to the current user's identity, and I don't know how to implement this in a query.
The Util class contains both invokeChainCode and queryChainCode methods, but the BusinessNetworkConnection class has only the submitTransaction transaction method that uses invokeChainCode and doesn't return any value.
What is the correct way of getting data from the chaincode, apart from copying and modifying the code for submitTransaction?
As far as I can understand your question, you wish to return some values from a transaction.
Assuming that the transaction is of Invoke Type (not query) then whatever you are returning from the chain code (for example shim.Success(someData);, it will be part of your transaction payload.)
So, in order to get that transaction payload from the transaction, you have to make sure its committed to the peer's ledger.
To be sure, just before you submit the transaction, you can subscribe to the transaction event using the given transaction id)
Ref:
https://github.com/hyperledger/fabric-samples/blob/release/balance-transfer/app/invoke-transaction.js#L90
EventHub : https://fabric-sdk-node.github.io/EventHub.html
Once you receive this event you can be sure that your transaction is successfully committed in the peer.
You can use the same transaction ID you can query a peer for the transaction block.
Ref : https://github.com/hyperledger/fabric-samples/blob/release/balance-transfer/app/query.js#L95
Channel.queryTransaction : https://fabric-sdk-node.github.io/Channel.html#queryTransaction__anchor
Once you get the transaction payload in JSON you can dig into the JSON and find the return value in proposal response part of the JSON payload.
[P.S. Assuming you are using Node JS SDK]
EDIT 1:
Hyperledger Fabric supports only 2 types of transactions on a broader level.
Invoke - If you send the proposal response to the orderer then your values (if any) are written to the state otherwise, any queried value are returned as a part of the proposal response payload.
Deploy - In case of Chaincode deployment transactions where the payload is just a chaincode binary.
So, in case you have read only transaction then you could just submit the transaction and get the proposal response payload from the peer(s). The proposal response itself is the result of your query invocation.
Currently, I am working on a project to integrate mysql with the IOCP server to collect sensor data and verify the collected data from the client.
However, there is a situation where mysql misses a connection.
The query itself is a simple query that inserts a single row of records or gets the average value between date intervals.
The data of each sensor flows into the DB at the same time every 5 seconds. When the messages of the sensors come on occasionally or overlap with the message of the client, the connection is disconnected.
lost connection to mysql server during query
In relation to throwing the above message
max_allowed_packet Numbers changed.
interactive_timeout, net_read_timeout, net_write_timeout, wait_timeout
It seems that if there are overlapping queries, an error occurs.
Please let me know if you know the solution.
I had a similar issue in a MySQL server with very simple queries where the number of concurrent queries were high. I had to disable the query cache to solve the issue. You could try disabling the query cache using following statements.
SET GLOBAL query_cache_size = 0;
SET GLOBAL query_cache_type = 0;
Please note that a server restart will enable the query cache again. Please put the configuration in MySQL configuration file if you need to have it preserved.
Can you run below command and check the current timeouts?
SHOW VARIABLES LIKE '%timeout';
You can change the timeout, if needed -
SET GLOBAL <timeout_variable>=<value>;
I’m trying to run a Dataset to build a KPI on SSRS 2016 Enterprise addition but, it give me the hereunder message although it run fine on the Report Builder:
[An Error has occurred.
The data set could not be processed .
There was a problem getting data from the Report server Web Services.]
I already changed the Dataset Timeout to Zero and the Database Query Time out to Zero on the RsReportServer.config
When I limit the Dataset to one row (a shorter query) it run fine which, mean the issue could be in the Web service or session timeout.
Setting Time-out Values for Report and Shared Dataset Processing (SSRS)
You can Reporting Services specify time-out values to set limits on
how system resources are used. Report server supports two time-out
values: An embedded dataset query time-out value is the number of
seconds that the report server waits for a response from the
database. This value is defined in a report.
A shared dataset query time-out value is the number of seconds that
the report server waits for a response from the database. This value
is part of the shared dataset definition and can be changed when you
manage the shared dataset on the report server.
A report execution time-out value is the maximum number of seconds
that report processing can continue before it is stopped. This value
is defined at the system level. You can vary this setting for
individual reports.
Most time-out errors occur during query
processing. If you are encountering time-out errors, try increasing
the query time-out value. Make sure to adjust the report execution
time-out value so that it is larger than the query time-out. The time
period should be sufficient to complete both query and report
processing.
https://learn.microsoft.com/en-us/sql/reporting-services/report-server/setting-time-out-values-for-report-and-shared-dataset-processing-ssrs
I'm working on a system which uses versant object database.
We have functional tests which sends requests to the server, server performs requested operation on database and returns results.
Afterwards we send an opposite request which is supposed to restore db to previous state untill next test starts.
This is invalid approach, we try to restore db to previous state using the very same request we are testing.
Is there a feature similar to Oracle Flashback in Versant, if not what is the proper way to handle this problem?