-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persistence enhancements - including adding PostgreSQL support #85
Conversation
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #85 +/- ##
=========================================
Coverage 99.97% 99.97%
=========================================
Files 61 75 +14
Lines 3504 4914 +1410
=========================================
+ Hits 3503 4913 +1410
Misses 1 1
|
…orage optimization Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
…er routines Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
There are two parts to the 409 processing:
|
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
.golangci.yml
Outdated
@@ -11,6 +11,11 @@ linters-settings: | |||
gosec: | |||
excludes: | |||
- G402 | |||
revive: | |||
rules: | |||
- name: unused-parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge deal, but why disable this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me go back to this - in a recent update (I think coupled to 1.19 maybe) unused parameters on all functions have to be renamed down to _
. I have been updating all the repos where I find it. I can't remember why I didn't just do that here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I put it back, and it only found one remaining issue. So I probably did it temporarily and forgot to remove it - thanks for the catch 👍
@@ -44,6 +45,7 @@ var ( | |||
ConfigConfirmationsNotificationsQueueLength = ffc("config.confirmations.notificationQueueLength", "Internal queue length for notifying the confirmations manager of new transactions/events", i18n.IntType) | |||
ConfigConfirmationsRequired = ffc("config.confirmations.required", "Number of confirmations required to consider a transaction/event final", i18n.IntType) | |||
ConfigConfirmationsStaleReceiptTimeout = ffc("config.confirmations.staleReceiptTimeout", "Duration after which to force a receipt check for a pending transaction", i18n.TimeDurationType) | |||
ConfigConfirmationsReceiptWorkers = ffc("config.confirmations.receiptWorkers", "Number of workers to use to query in parallel for receipts", i18n.IntType) | |||
|
|||
ConfigTransactionsMaxHistoryCount = ffc("config.transactions.maxHistoryCount", "The number of historical status updates to retain in the operation", i18n.IntType) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just below here is a DeprecatedConfigTransactionsNonceStateTimeout
, which I believe has been un-deprecated, and further down is a ConfigTXHandlerNonceStateTimeout
among the "simple" handler configs, which I think has been deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for leaving you to work this out 🤦 - yes you're 100% right
internal/tmconfig/tmconfig.go
Outdated
@@ -113,7 +127,7 @@ func setDefaults() { | |||
|
|||
// Deprecated default values for transaction handling configurations | |||
viper.SetDefault(string(DeprecatedTransactionsMaxInFlight), 100) | |||
viper.SetDefault(string(DeprecatedTransactionsNonceStateTimeout), "1h") | |||
viper.SetDefault(string(TransactionsNonceStateTimeout), "1h") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to move this away from the comment saying these configs are deprecated
internal/tmmsgs/en_error_messges.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filename has a typo
internal/tmmsgs/en_error_messges.go
Outdated
MsgSQLScanFailed = ffe("FF21082", "Failed to read value from DB (%T)") | ||
MsgShuttingDown = ffe("FF21083", "Connector shutdown initiated", 500) | ||
MsgTransactionPersistenceError = ffe("FF21084", "Failed to persist transaction data", 500) | ||
MsgOpNotSupportedWithoutRichQuery = ffe("FF21085", "Not supported: The connector must be configured with a rich query database to support this operation", 405) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this is strictly a case for HTTP 405 (that's usually when you POST something that only supports GET, or similar). HTTP 501 might be more correct?
features := dbsql.DefaultSQLProviderFeatures() | ||
features.PlaceholderFormat = sq.Dollar | ||
features.UseILIKE = false // slower than lower() | ||
features.AcquireLock = func(lockName string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like this functionality is ever used, so it's questionable if we should require implementing it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wider pain point here, is that the PSQL handler is implemented in multiple repos - copy/paste.
This was because we didn't want to add the whole postgres library import to the base common functionality. Might be worth revisiting.
For this PR, the code is a carbon copy of what's in other repos.
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
Signed-off-by: Peter Broadhurst <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ended up being multiple large items coupled together (adding a new database choice along with a pretty comprehensive rewrite of the transaction and confirmation handling). It seems like a major step forward on many fronts, but it's tough to wrap my head around all the changes at once.
That said, everything seems architecturally sound, and I couldn't see any obvious problems. I think this will just need a lot of exercise and testing to ensure it functions as intended.
Signed-off-by: Peter Broadhurst <[email protected]>
Work in progress - release should be marked v1.3 when complete/merged.
Depends on hyperledger/firefly-common#71
Potential migration impacts
transactionHeaders
on the managed transaction that repeats some of the base fields, but only populates others, has been removed.transactions.nonceStateTimeout
previously deprecated, re-instatedtransactions.handler.simple.nonceStateTimeout
removedreceipt
section is only populated on/transactions/{transactionId}
not on the collection queryconfirmations
section is only populated on/transactions/{transactionId}
not on the collection queryhistory
section is only populated on/transactions/{transactionId}
not on the collection querysummary
section of a transaction is marked deprecated, and only populated for LevelDB - not implemented at all for PSQLPersistence changes
Making as pragmatic as possible change to the persistence mechanism, to support PostgreSQL as an alternative to LevelDB when persisting transactions, checkpoints, subscriptions, and listeners.
Aiming to make the impact on policy engine extensions as minimal as possible, but there are some changes shaping up:
TXHistory
moving into persistence, as implementation will be fundamentally different for PSQL to LevelDBerror
and only take theID
of theManagedTX
object (not the full object)ManagedTX
object into core object fields, and related objects that can be merged in during aGET
operation for backwards compatibilityHistory
/HistorySummary
were the big thingsTransactionHeaders
ended up a bit confused, so I've attempted to reconcile it (more info owed by me here)Receipt
- TBD if this stays separate- LevelDB continues to be a single fat JSON payload
WriteTransaction
function with anew
boolean, moved toInsertTransaction
andUpdateTransaction
- with clearer update semantics- This avoid re-writing huge JSON blobs to SQL DBs when simply tweaking a status field
Confirmations
notification system:- Notifying for all confirmations as we detect them, rather than only once the full set is completed (UX improvement)
- Providing a more rich confirmations notification that can distinguish incremental adding of confirmations, from a new fork
Other changes