Browse Source
Split the batched RPC persistence into a create path (INSERT ... ON CONFLICT) and an update path (UPDATE ... WHERE id = ?). A status update for a row deleted in the meantime (TTL cleanup / manual delete) is no longer resurrected, restoring the old findById-null skip. Both paths COALESCE the response so a status update that carries none no longer clobbers a previously stored one. The create-vs-update intent is carried by a dedicated RpcQueueEntry record (keeping RpcEntity pure data) and exposed via explicit createAsync/updateAsync DAO methods instead of a boolean flag; insert/update batch scaffolding is collapsed into a shared helper. Adds DAO regression tests (re-queue keeps existing row, null-response preservation, no resurrection of a deleted row) and TbRpcService create/update wiring tests.pull/15853/head
10 changed files with 212 additions and 39 deletions
@ -0,0 +1,34 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2026 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.dao.sql.rpc; |
||||
|
|
||||
|
import org.thingsboard.server.dao.model.sql.RpcEntity; |
||||
|
|
||||
|
/** |
||||
|
* Pairs an {@link RpcEntity} with the write intent for the batched persistence queue, so the entity |
||||
|
* itself stays pure data. {@code insert} selects INSERT-on-conflict (initial create) vs UPDATE-by-id |
||||
|
* (status change that must never resurrect a deleted row). |
||||
|
*/ |
||||
|
record RpcQueueEntry(RpcEntity entity, boolean insert) { |
||||
|
|
||||
|
static RpcQueueEntry forInsert(RpcEntity entity) { |
||||
|
return new RpcQueueEntry(entity, true); |
||||
|
} |
||||
|
|
||||
|
static RpcQueueEntry forUpdate(RpcEntity entity) { |
||||
|
return new RpcQueueEntry(entity, false); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue