Files
ha/service-mgmt/sm-db/src/sm_db.h
Bin Qian 05a01c2100 Fix SQLite3 concurrent access issue
SQLite3 does not support concurrent access with multiple connections
that have writeable access. Currently SM opens database connections
with full access, which causes concurrent issue.

This fix includes:
1. open readonly connection whenever the write permission is not needed
2. remove code that open connections that are not being used
3. remove reattempt and loggings from previous partial fix

Now all writable connections are opened and used in main thread, this
can ensure no more concurrent issue.

Closes-Bug: 1915894
Signed-off-by: Bin Qian <bin.qian@windriver.com>
Change-Id: I200647a3733ac899b0b7498abd52992c7a87bd32
2021-03-18 11:08:27 -04:00

113 lines
4.4 KiB
C

//
// Copyright (c) 2014 Wind River Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
#ifndef __SM_DB_H__
#define __SM_DB_H__
#include <stdbool.h>
#include "sm_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void SmDbHandleT;
typedef void SmDbStatementT;
// ****************************************************************************
// Database - Statement Result Reset
// =================================
extern SmErrorT sm_db_statement_result_reset( SmDbStatementT* sm_db_statement );
// ****************************************************************************
// ****************************************************************************
// Database - Statement Result Step
// =================================
extern SmErrorT sm_db_statement_result_step( SmDbStatementT* sm_db_statement,
bool* done );
// ****************************************************************************
// ****************************************************************************
// Database - Transaction Start
// ============================
extern SmErrorT sm_db_transaction_start( SmDbHandleT* sm_db_handle );
// ****************************************************************************
// ****************************************************************************
// Database - Transaction End
// ==========================
extern SmErrorT sm_db_transaction_end( SmDbHandleT* sm_db_handle );
// ****************************************************************************
// ****************************************************************************
// Database - Statement Initialize
// ===============================
extern SmErrorT sm_db_statement_initialize( SmDbHandleT* sm_db_handle,
const char* sql_statement, SmDbStatementT** sm_db_statement );
// ****************************************************************************
// ****************************************************************************
// Database - Statement Finalize
// =============================
extern SmErrorT sm_db_statement_finalize( SmDbStatementT* sm_db_statement );
// ****************************************************************************
// ****************************************************************************
// Database - Connect
// ==================
extern SmErrorT sm_db_connect( const char* sm_db_name,
SmDbHandleT** sm_db_handle, bool readonly = false );
// ****************************************************************************
// ****************************************************************************
// Database - Disconnect
// =====================
extern SmErrorT sm_db_disconnect( SmDbHandleT* sm_db_handle );
// ****************************************************************************
// ****************************************************************************
// Database - Configure
// ====================
extern SmErrorT sm_db_configure( const char* sm_db_name, SmDbTypeT sm_db_type );
// ****************************************************************************
// ****************************************************************************
// Database - Build
// ================
extern SmErrorT sm_db_build( const char* sm_db_name, SmDbTypeT sm_db_type );
// ****************************************************************************
// ****************************************************************************
// Database - Integrity Check
// ==========================
extern SmErrorT sm_db_integrity_check( const char* sm_db_name,
bool* check_passed );
// ****************************************************************************
// ****************************************************************************
// Database - Checkpoint
// =====================
extern SmErrorT sm_db_checkpoint( const char* sm_db_name );
// ****************************************************************************
// ****************************************************************************
// Database - Initialize
// =====================
extern SmErrorT sm_db_initialize( void );
// ****************************************************************************
// ****************************************************************************
// Database - Finalize
// ===================
extern SmErrorT sm_db_finalize( void );
// ****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __SM_DB_H__