Commit Graph
111 Commits
Author SHA1 Message Date
Chetan GowdaandGitHub c15f9436be Add tests for the fix in PR #6538 (#6652)
## What changed?
A critical bug was fixed in PR #6538. These are the associated tests to
prevent regression.

## Why?
Adding tests for a bug fix.

## How did you test it?
Reverted the PR locally and ensured the tests catch it.

## Potential risks
N/A
2024-10-15 15:25:58 -04:00
Jacob BarzeeandGitHub 06171037f0 Import alignment (#6426)
## What changed?
Make import formatting a part of the build, and test validity with
"ensure-no-changes" target

## Why?
So we never discuss import order again (hopefully)

## How did you test it?
its a build change, so the build will test it!

## Potential risks
As long as build works, the only thing I risk is the ire of coworker who
want imports to be different ;)

## Documentation
N/A

## Is hotfix candidate?
No
2024-08-23 14:48:10 -06:00
YuriandGitHub 3eb4154958 Add start_time column to the current execution table. Some refactoring (#6310)
## What changed?
Add "start_time" nullable column to the current_executions table. 
Some refactoring of the existing code - send row as a parameter rather
then every single field of that row.

## Why?
Adding column - to allow fast checking workflow creation time to avoid
noisy workflow restarts. Without it we need to get workflow start time
from a mutable state, which can affect latency.

## Is hotfix candidate?
No
2024-07-24 14:17:46 -07:00
Daniel KimandGitHub 6ac5c584d7 Support sql connector (#5265)
## What changed?
SQL config now supports passing a connect function.

## Why?
It's currently not possible to embed a Temporal server to a host
application where the database connection is managed by the host
application and is provided as a database connector. This allows the
host application to pass a db connector rather than the the individual
sql config strings.

## How did you test it?
I have embedded this code into a custom application and verified that
the connector is working properly.

## Potential risks
This is a non-breaking change with very minimal risks.

## Is hotfix candidate?
No.
2024-05-24 14:39:46 -07:00
Tim Deeb-SwihartandGitHub be7b5514a5 Reconnect to SQL databases when connections fail (#5926)
## What changed?

Both our PostgreSQL and MySQL database backends will now automatically
reconnect to the database when certain errors occur: all errors chosen
have been experienced when testing this behavior through an AWS Aurora
RDS failover of either MySQL or PostgreSQL.

For both backends we will reconnect when we see:
- `ECONNRESET`
- `ECONNABORTED`
- `ECONNREFUSED`
- `io.EOF`
- `io.ErrUnexpectedEOF`
- `database/sql/driver.ErrBadConn`

for postgres we will also reconnect on the following SQLStates:
- `25006` read-only transaction
- `57P03` cannot connect now
- `0A000` feature not supported, but ONLY when the message is `cannot
set transaction read-write mode during recovery`

for mysql we will also reconnect when we see the following error codes:
- `1040` too many connections 
- `1792` read-only transaction (SQLstate `25006`)
- `1836` running in read-only mode

This logic is easily extensible should we discover more failure modes
over time

## Why?

We've had multiple community reports of Temporal problems during RDS
failover. One part of this is the fact that we wouldn't necessarily
reconnect; we were at the whims of our chosen SQL abstraction's
connection pooling logic.

## How did you test it?

I manually tested this functionality in the presence of repeated RDS
failovers: 

- [x] postgres12 plugin with pq driver
- [x] postgres12 plugin with pgx driver
- [x] mysql plugin

Automated testing will be added to our regular testing pipelines once
our infrastructure friends have added the support I need (it's in
progress)

## Potential risks

We're concerned there's a correctness issue in our PostgreSQL backend
that's related to our behavior during an RDS failover. If we merge this
before I figure out what's going on, we could hide the issue and make it
harder to reproduce.

## Documentation
N/A

## Is hotfix candidate?
Yes?
2024-05-17 16:59:15 -07:00
Roey BermanandGitHub f6a0b43a8c Nexus Endpoints (#5855)
## What changed?

- Refactored Nexus Registry code to merge incoming and outgoing into one
registry
- Added separate concept of "endpoints" - which is roughly analogous to
what was previously called "services"
- Upgraded the Nexus Go SDK and API dependencies accordingly
- Command handler interface was modified to accept a context given new
requirements
- Note that invoking a worker endpoint is not yet supported, there will
be some minor restructuring required to enable that
- Requires this unmerged API PR
https://github.com/temporalio/api/pull/403. The two PRs should be merged
together.
## Why?

Part of late redesign. See also https://github.com/nexus-rpc/api/pull/5

## How did you test it?

Modified existing and added new tests.
2024-05-09 12:17:52 -07:00
ShahabTandDavid Reiss 696df9e190 Merge versioning-2 branch into main 2024-04-12 13:30:59 -07:00
ShivamandDavid Reiss 6fd938d17f Removed CreateTask from db and persistence layer (#5606)
## What changed?
Noticed that `db.CreateTask` and `persistence.CreateTask` were
relatively unused and could be removed.

## How did you test it?
Current CI/CD tests

## Potential risks
Could break things if an unseen component were to use these methods;
have checked it to the best of my abilities.

## Is hotfix candidate?
No
2024-04-12 11:48:50 -07:00
f42120be73 Add GetNexusIncomingService persistence API (#5616)
## What changed?
<!-- Describe what has changed in this PR -->
Added a new persistence layer API to get a Nexus incoming service by
service ID.

## Why?
<!-- Tell your future self why have you made these changes -->
To align with new API requirements

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Updated existing tests

---------

Co-authored-by: Roey Berman <[email protected]>
2024-03-28 11:20:43 -07:00
55771ce32d Nexus accumulated work (#5225)
This PR is intended to merge 4 months of work in the `nexus` feature
branch into `main`.

The functionality it brings is:
- Dispatching Nexus Tasks by namespace and task queue
- Internal implementation of the Incoming Service Registry - not yet
exposed
- Attaching workflow close callbacks on `StartWorkflowExecutionRequest`
and processing of those callbacks

There's more to come and some of the callback code will be refactored
into a new plugin architecture
(https://github.com/temporalio/temporal/pull/5446) soon.

---------

Co-authored-by: PJ Doerner <[email protected]>
2024-03-05 22:37:21 +00:00
Rodrigo ZhouandGitHub 2c12548f8e Refactor var names related to visibility mysql8 and postgres12 (#5464)
## What changed?
<!-- Describe what has changed in this PR -->
Rename vars related to visibility.

## Why?
<!-- Tell your future self why have you made these changes -->
Ease to read code.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Existing unit tests.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
No.

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
No
2024-02-29 13:54:30 -06:00
Rodrigo ZhouandGitHub 0280e70e5b Remove support for standard visibility (#5387)
## What changed?
<!-- Describe what has changed in this PR -->
Remove support for standard visibility

## Why?
<!-- Tell your future self why have you made these changes -->
Standard visibility is deprecated.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2024-02-29 12:05:20 -06:00
Prathyush PVandGitHub ca6807860b Adding MessageCount to ListQueues response (#5130)
<!-- Describe what has changed in this PR -->
**What changed?**
Adding a new field MessageCount to ListQueues response.

<!-- Tell your future self why have you made these changes -->
**Why?**
This field will be useful for operators who wants to get details about
DLQs

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Unit tests with 100% test coverage.

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**


<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
2023-11-20 15:10:30 -08:00
Prathyush PVandGitHub 65a44e18ba Adding ListQueues for Cassandra and SQL (#5098)
<!-- Describe what has changed in this PR -->
**What changed?**
Adding ListQueues API to QueueV2 and implementing it for Cassandra and
SQL

<!-- Tell your future self why have you made these changes -->
**Why?**
This API can be used by operators to list different types of queues
including DLQs.

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Unit tests with 100% coverage.

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**


<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
2023-11-13 18:23:37 -08:00
Prathyush PVandGitHub d98eb745ad Adding FOR UPDATE for SelectFromQueueV2Metadata (#5075)
<!-- Describe what has changed in this PR -->
**What changed?**
Adding FOR UPDATE clause when fetching queueV2 metadata and removing
unused field version from queue metadata.

<!-- Tell your future self why have you made these changes -->
**Why?**
If a queueV2 metadata row is fetched in a transaction, we have to place
a lock on that row
to avoid another transaction reading from that line. This can happen
when two threads are trying to
delete messages from the queue. Two of them will update queue metadata
and write it back. This will lead
to a race condition. By adding 'FOR UPDATE' SQL clause, the first
transaction will get an exclusive lock
on the row. The second transaction will wait until the first transaction
is complete or rollback.

Also, removing the version field from QueueV2 metadata table. We will
not be using this field since we are using sql transactions.


<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Unit test. Executed through the debugger to make sure
SelectFromQueueV2MetadataForUpdate() is called instead of
SelectFromQueueV2Metadata() when executed inside a trancation.


<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**


<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
2023-11-04 09:56:35 -07:00
dd6f2b313c Adding RangeDelete and CreateQueue methods for QueueV2 SQL Implementation (#4980)
<!-- Describe what has changed in this PR -->
**What changed?**
Adding RangeDeleteMessages() and CreateQueue() methods for SQL version
of persistence.QueueV2, which supersedes the persistence.Queue
interface.


<!-- Tell your future self why have you made these changes -->
**Why?**
We plan on using this for the upcoming history task DLQ project.


<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Unit tests. Code has 100% unit test coverage.


<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**


<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**

---------

Co-authored-by: Michael Snowden <[email protected]>
2023-10-20 13:20:38 -07:00
Prathyush PVandGitHub 720ebc5a14 EnqueueMessage and ReadMessage methods for QueueV2 SQL Implementation (#4937)
<!-- Describe what has changed in this PR -->
**What changed?**
Adding EnqueueMessage() and ReadMessage() methods for SQL version of
persistence.QueueV2, which supersedes the persistence.Queue interface.
The implementations for delete and merge are left out for now and will
be implemented later.


<!-- Tell your future self why have you made these changes -->
**Why?**
We plan on using this for the upcoming history task DLQ project.


<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Unit tests.

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**


<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
2023-10-10 09:57:37 -07:00
Nikolay TretyakandGitHub 87ea6512d4 pgx support (#4913)
<!-- Describe what has changed in this PR -->
**What changed?**
`Driver` interface (with two implementations) was added to the
postgresql persistence package in order to support other drivers than
`lib/pq`. Fixes https://github.com/temporalio/temporal/issues/1775

Essentially, this PR does
https://github.com/temporalio/temporal/pull/4914 in a
backward-compatible and extendable way

<!-- Tell your future self why have you made these changes -->
**Why?**
Since `lib/pq` does not support multi-node clusters


<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Existing tests


<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
No, since you should explicitly change the driver in your config file.
However, `connectAttributes` depend on the driver (e.g.,
`binary_parameters` is supported only by `lib/pq` and is not a part of
postresql standard), so one should be careful changing drivers in
production.


<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
No
2023-10-09 17:38:51 -05:00
Alexandre VilainandGitHub 517443da3b Fix temporal-sql-tool database creation on postgresql when database name contains hyphen (#4735)
<!-- Describe what has changed in this PR -->
**What changed?**

Added double quotes around database name in the create database query
for PostgreSQL.

<!-- Tell your future self why have you made these changes -->
**Why?**

The issue has been created on temporal-operator project (see:
https://github.com/alexandrevilain/temporal-operator/issues/402).
When we try to use the `temporal-sql-tool` `create` command with a
database name containing hyphen(s), even if escaped in command, it
throws the following error: `pq: syntax error at or near \"-\"`.

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**

Before the fix:
```bash
$ go run ./cmd/tools/sql --endpoint="localhost" --port="5432" --user="temporal-aws-dev" --password="$TEMPORAL_DEFAULT_DATASTORE_PASSWORD" --database="temporal-aws-dev" --plugin="postgres" create
2023-08-05T20:44:58.957+0200    ERROR   Unable to create SQL database.  {"error": "pq: syntax error at or near \"-\"", "logging-call-at": "handler.go:94"}
exit status 1
```

After the fix:
```bash
$ go run ./cmd/tools/sql --endpoint="localhost" --port="5432" --user="temporal-aws-dev" --password="$TEMPORAL_DEFAULT_DATASTORE_PASSWORD" --database="temporal-aws-dev" --plugin="postgres" create
$ echo $?
0
```

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
Nothing.

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
No.
2023-09-25 11:34:41 -05:00
Rodrigo ZhouandGitHub f144062d7f Support count group by in visibility with SQL (#4666) 2023-07-27 16:03:09 -05:00
Roey BermanandGitHub a30e8a2e7d Implement build id scavenger (#4430) 2023-06-09 10:36:38 -07:00
Matt McShaneandGitHub 932003d936 Inline UpdateInfo Storage (#4420)
* Revert "Capture UpdateInfos in MutableState mutation (#4372)"

This reverts commit c78ee02eee.

* Revert "Adds update state indexing to MutableState (#4224)"

This reverts commit f8303d8e7e.

* Add UpdateInfo map to WorkflowExecutionInfo

This inlines the UpdateInfo index into the pre-existing execution blob
so that downstream persistence implementations won't see any change.
2023-05-31 13:46:55 -04:00
Roey BermanandDavid Reiss fea92f6358 Address comments from #4346 review (#4405)
Note: This commit came from a feature branch and is not expected to build.
2023-05-26 16:03:31 -04:00
Roey BermanandDavid Reiss d98b6668b0 Worker versioning leftovers (#4400)
Note: This commit came from a feature branch and is not expected to build.
2023-05-26 16:03:31 -04:00
Roey BermanandDavid Reiss cbfa37e0af Implement GetWorkerTaskReachability API (#4346)
Note: This commit came from a feature branch and is not expected to build.
2023-05-26 16:03:31 -04:00
Roey BermanandDavid Reiss 8a2a3e7a6a Implement task queue user data seed (forced replication) (#4259)
Note: This commit came from a feature branch and is not expected to build.
2023-05-26 16:03:31 -04:00
Roey BermanandDavid Reiss e3b52e558d Refactor to use new protos and persistence (#4194)
Note: This commit came from a feature branch and is not expected to build.
2023-05-26 16:03:31 -04:00
Yu XiaandGitHub 2218dea8fb Add replication dlq metrics (#3876) 2023-05-11 17:33:24 -07:00
Matt McShaneandGitHub f8303d8e7e Adds update state indexing to MutableState (#4224)
Add UpdateInfo records to MutableState

A mechanism for storing pointers into the workflow history representing
update accepted or completed events. Storage added for Cassandra,
PosgtreSQL, MySQL, and SQLite.
2023-05-03 12:24:32 -04:00
Yichao YangandGitHub 0befbfc700 Remove unused persistence GetHistoryTask API (#4003) 2023-03-06 14:32:18 -08:00
Rodrigo ZhouandGitHub b2a733823e Support CountWorkflowExecutions for SQL DB (#3955) 2023-02-14 16:59:12 -08:00
Alex ShtinandGitHub 743be2c562 Fix ExecutionTime rounding when using PostgreSQL (#3952) 2023-02-13 18:50:13 -08:00
Rodrigo ZhouandGitHub d7f4606485 Advanced visibility for PostgreSQL (#3896) 2023-02-02 22:16:37 -08:00
Rodrigo ZhouandGitHub d49786debf [Advanced Visibility with SQL] Adding PostgreSQL 12 schema and interface (#3844)
* Create base schema for PostgreSQL 12

* Changes to PostgreSQL 12 visibility schame to support advanced visibility

* Create PostgreSQL 12 db interface and configs
2023-01-31 14:35:51 -08:00
Rodrigo ZhouandGitHub 7e1ddb70dc Add GetIndexName method to visibility manager (#3820) 2023-01-27 00:44:39 -08:00
Rodrigo ZhouandGitHub 77f0af8625 Fix time fields of rows from GetClusterMembers (#3840) 2023-01-25 17:18:50 -08:00
Rodrigo ZhouandGitHub f5c2446dc3 Fix GetWorkflowExecution in PostgreSQL (#3816) 2023-01-24 12:20:45 -08:00
Yichao YangandGitHub b5ff033db0 Support arbitrary history task category in SQL persistence (#3489) 2022-10-19 16:08:01 -07:00
Rodrigo ZhouandGitHub 4213f95d0f Create visibility GetWorkflowExecution API (#3488) 2022-10-17 19:26:16 -07:00
Michael SnowdenandGitHub 73f94d9300 Implement GetAllHistoryTreeBranches for SQL persistence backends (#3438) 2022-09-29 17:00:06 -07:00
Alexander MaysandGitHub 74c74e0a45 Remove rds iam auth plugin (#3079)
* Revert "Fix auth plugin configuration to match the new SQLAuthPlugin config block (#2844)"

This reverts commit 37ab2b5664.

* Revert rds-iam-auth - current drivers dont support authentication callbacks

Signed-off-by: Alexander Mays <[email protected]>
2022-07-10 14:31:02 -07:00
Alexander MaysandGitHub b8f3f89555 Add RDS IAM auth plugin for SQL drivers (#2830)
Signed-off-by: Alexander Mays <[email protected]>
Added:
A new environment variable to the CLI: SQL_AUTH_PLUGIN=rds-iam-auth
A new flag arg to the CLI: --sql-auth-plugin rds-iam-auth
2 new docker template variables: authPlugin: {{ default .Env.SQL_AUTH_PLUGIN "" }} and authPlugin: {{ default .Env.SQL_VIS_AUTH_PLUGIN "" }}
A new SQL configuration attribute authPlugin
2022-05-12 16:28:26 -07:00
Jeremy BreidingandGitHub 5d0296a421 Add sqlite persistence tests (#2681)
* Add sqlite persistence tests

* fix up a test

* Remove limit on prune operation for sql plugin
2022-03-30 13:05:33 -07:00
Yichao YangandGitHub ae23339fca Make matching persistence range queries [inclusive, exclusive) (#2599)
- Range for matching GetTasks is now [inclusive, exclusive), instead of (exclusive, inclusive]
- Range for matching CompleteTasksLessThan is now < max TaskID, instead of <=
- Range for admin ListTaskQueueTasks is now [inclusive, exclusive)
2022-03-15 10:42:12 -07:00
Yichao YangandGitHub be2e4a2d56 Support pagination for SQL GetTransfer/VisibilityTasks (#2564)
- support pagination for sql GetTransfer/VisibilityTasks
- improve pagination for sql GetTimer/ReplicationTasks
- new ExecutionMutableStateTaskSuite suite
2022-03-04 12:29:31 -08:00
Yichao YangandGitHub 3896610a3d Unify history task persistence range query behavior (#2547)
- Make range based on taskID and task fire time both [inclusive, exclusive)
2022-02-28 12:08:18 -08:00
Jeremy BreidingandGitHub a5ddc3ca73 Sql task queue visibility (#2537)
* Adding task_queue to read/write paths
for postgresql executions_visibility

* Adding task_queue for mysql and sqlite
2022-02-24 18:22:46 -08:00
Mikhail GryzykhinandGitHub ef2063c9e5 Add support for GetWorkflowHistory in reverse order (#2442)
Add API to fetch workflow history in reverse order
2022-02-14 12:49:02 -08:00
Yichao YangandGitHub 13b102065e Remove unused queue processor (#2473) 2022-02-08 10:39:11 -08:00
wxing1292andGitHub 7258e62519 Separate SQL session management into a dedicated file (#2391)
* Create reusable MySQL session util
* Create reusable PostgreSQL session util
2022-01-19 13:33:07 -08:00