A real-time database storage space control management method
By managing the real-time database storage space using ordered tables, the problem of improper management of real-time database storage space is solved, and the stability and real-time requirements of the storage space are met.
Patent Information
- Application Number
- CN202111154728.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-29
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2041-09-29
AI Technical Summary
The existing real-time database cannot automatically delete early data, resulting in a gradual increase in storage space, making it impossible to effectively manage storage space and affecting system stability.
A method combining ordered tables and real-time databases is adopted. The ordered tables manage the storage space of the real-time database, configure the maximum number of records, and delete the oldest record when the maximum number is reached, thus ensuring the stability of the storage space.
It enables autonomous management of real-time database storage space, ensuring that the storage space remains stable, avoiding insufficient hard disk space, and meeting real-time requirements.
Smart Images

Figure CN115878607B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a real-time database storage space control management method, belonging to the technical field of computer information management. BACKGROUND
[0002] Process control systems are generally distributed computing-based systems, and especially in the field of production enterprise process control, the real-time requirements of the system are high, so real-time databases are generally used as data exchange platforms between processes.
[0003] The existing real-time database can quickly realize the function of searching according to the key and value, and the efficiency is high. However, there are still some problems: the data of the real-time database is stored in disorder, and it is impossible to realize automatic deletion of early data through the API interface provided by the manufacturer; the real-time database has the function of searching records according to the key and value quickly, but the traversal operation is very time-consuming, and the method of deleting according to the time stamp through traversal records is also not feasible; the real-time database does not have a dedicated management software, and it is impossible to allocate the size of the storage space and the size of the data, so with the passage of time, the capacity of the real-time database will become larger and larger, eventually leading to insufficient hard disk space and causing system downtime; due to the high requirement of real-time, it is not allowed to operate through the early data positioned by the relational database. SUMMARY
[0004] The technical problem to be solved by the present application is to overcome the shortcomings of the above-mentioned technologies, and to provide a real-time database storage space control method, so as to realize the autonomous management of the real-time database storage space and ensure that the storage space is automatically maintained at a stable and controllable value.
[0005] In order to solve the above technical problems, the technical solution provided by the present application is: a real-time database storage space control management method, comprising the following steps:
[0006] Step 1: Establish an ordered table, the ordered table contains a plurality of records corresponding to the records in the real-time database, each record of the ordered table contains a corresponding key and value, and each record in the real-time database also contains a corresponding key and value; the data of the key of the ordered table is a serial number, the data of the value of the ordered table is the data of the key of the real-time database, and the value of the ordered table corresponds to the key of the real-time database one by one; the records in the ordered table are arranged in order according to the serial number in the key;
[0007] Step 2: When a record is added in the real-time database, the ordered table also performs an adding record operation, wherein the data of the key of the ordered table is the key of the first record of the ordered table plus the number of records of the ordered table, and the data of the value of the ordered table is the data of the key of the real-time database;
[0008] Step 3: A maximum record number is configured for the real-time database, when the record number of the ordered table exceeds the maximum record number, the key of the earliest added record of the real-time database is located through the first record of the ordered table, the corresponding record is located in the real-time database according to the key value, and the record is deleted to release space, and the first record is deleted from the ordered table;
[0009] Step 4: When the maximum record number is modified to a smaller value, the records exceeding the current maximum record number in the ordered table are deleted in a first-in first-out order when the real-time database is restarted, until the record number in the ordered table is no longer greater than the current maximum record number, and the function of dynamically modifying the storage space of the real-time database is realized.
[0010] The further improvement of the above scheme is that when the records of the ordered table and the real-time database are added and deleted, only one thread can access and edit the real-time database at the same time, and only when the real-time database and the ordered table are simultaneously added or successfully deleted, the operation is considered to be successfully completed, otherwise the operation is cancelled, and the ordered table and the real-time database are restored to the state before the operation.
[0011] The further improvement of the above scheme is that when the ordered table and the real-time database do not match, the unmatched records are cleared by traversing the real-time database, so that the records of the ordered table and the real-time database are matched.
[0012] The real-time database storage space control management method provided by the application can effectively control the storage space of the real-time database, and when the record number reaches the maximum number, the early data can be quickly deleted, and the storage space of the real-time database can be maintained at a stable value. BRIEF DESCRIPTION OF DRAWINGS
[0013] The application will be further described below with reference to the drawings.
[0014] Figure 1 is a storage structure schematic diagram of a preferred embodiment of the application.
[0015] Figure 2 is a flow chart of a preferred embodiment of the application. DETAILED DESCRIPTION EMBODIMENT
[0016] The real-time database storage space control management method of the embodiment, as shown in Figure 2 includes the following steps:
[0017] Step 1: as Figure 1The order table is established, and the order table includes a plurality of records corresponding to the records in the real-time database. Each record of the order table includes a corresponding key and value. Each record in the real-time database also includes a corresponding key and value. The data of the key of the order table is a serial number. The data of the value of the order table is the data of the key of the real-time database. The value of the order table corresponds to the key of the real-time database. The records in the order table are arranged in the order of the serial number in the key.
[0018] Step 2: When a record is added in the real-time database, the order table also adds a record. The data of the key of the newly added record of the order table is the key of the first record of the order table plus the number of records of the order table. The data of the value of the newly added record of the order table is the data of the key of the real-time database.
[0019] Step 3: A maximum number of records is configured for the real-time database. When the number of records of the order table exceeds the maximum number of records, the first record of the order table is located to the key of the earliest added record of the real-time database. Then, the corresponding record in the real-time database is located according to the key value. The record is deleted, the space is released, and the first record of the order table is deleted.
[0020] Step 4: When the maximum number of records is modified to a smaller value, the records exceeding the current maximum number of records are deleted from the order table in the order of first-in-first-out when the real-time database is restarted, until the number of records in the order table is no longer greater than the current maximum number of records, to realize the function of dynamically modifying the storage space of the real-time database.
[0021] When the order table and the real-time database are added and deleted, only one thread can access and edit the real-time database at the same time. The operation is considered to be successfully completed only when the real-time database and the order table are added or deleted successfully. Otherwise, the operation is revoked, and the order table and the real-time database are restored to the state before the operation. When the order table and the real-time database are added and deleted, considering the concurrency, resource locks are added to the order table and the real-time database during the addition and deletion operations. The resource locks ensure that only one thread can access and edit the real-time database at the same time, to avoid the generation of “dirty data” caused by the simultaneous operation of multiple threads on the real-time database. The operation is considered to be successfully completed only when the real-time database and the order table are added or deleted successfully. Otherwise, the records affected by the operation are revoked, and the order table and the real-time database are restored to the state before the operation, to ensure the atomicity of the operation and prevent the mismatch between the order table and the real-time database. In case of mismatch between the order table and the real-time database, the mismatched records can be cleared by traversing the real-time database, to ensure the matching between the order table and the real-time database.
[0022] When the ordered table and the real-time database do not match, the unmatched records are cleared by traversing the real-time database, so as to ensure that the records of the ordered table and the real-time database match.
[0023] Specifically, the laminar cooling strip real-time database in the Meisteel 1780 hot rolling L2 process control computer system is taken as an example for description. The Berkeley DB is adopted as the real-time database, and the key data of the database is a hot rolling strip coil number, which is composed of 11 strings and generated by a contract issued by an L3 system, and has disorder. An ordered table based on a Map is established by using the Freeze technology of the Ice platform, wherein the key / value are a serial number / hot rolling strip coil, and the variable types of the key / value are long long / string. The ordered table can automatically realize disk synchronization, so as to ensure synchronization with the real-time database records after program restart. When the real-time database record increasing operation is performed, the real-time database record number is compared with the maximum record number in the configuration file to determine whether the early data needs to be cleared.
[0024] Wherein:
[0025] 1, the configuration file configuration format is:
[0026] StripObjectDB.MaxStripCount = 100000;
[0027] which indicates that the maximum capacity is 100000 records;
[0028] 2, the ordered table definition manner is:
[0029] Slice2free - IC:\iPlature\Ice\Ice-3.4.1\bin –I D:\ABS08414\
[0030] 2SOURCE\slice –dict BDBIndexMap, long long, string, sort BDBIndexMap
[0031] Wherein long long indicates the ordered table key type, string indicates the stored value type, and sort indicates sorting according to the key.
[0032] 3, the real-time database definition manner is:
[0033] ObjectCache <stripobjecti>StripObjectDB;
[0034] Wherein ObjectCache is the storage entity of the real-time database, the storage content is StripObjectI object, the key value is string string type, and the value of the real-time database is used to store user-defined data, such as weight, width, thickness, production date and other data.
[0035] If the number of records of the real-time database exceeds the maximum number of records in the configuration file, the earliest added coil number is located by reading the first record of the ordered table, and then the real-time database data can be deleted and the space is released according to the coil number, so that the capacity of the physical disk space occupied by the real-time database is kept at a stable value.
[0036] Through program test, it is obtained that the operation time of deleting the earliest data is in the level of 10ms, which can completely meet the real-time requirement of the hot rolling process control system. Moreover, the key type of the ordered table is long long type, which is 64-bit integer data, and the maximum value can reach about 9.2*1018. According to the average production of 600 strips per day, the production of about 4 trillion strips per day can be stored without data overflow leading to order confusion.
[0037] The present application is not limited to the above-mentioned embodiments. Any technical solution formed by equivalent replacement falls within the protection scope required by the present application.< / stripobjecti>
Claims
1. A real-time database storage space control and management method, characterized in that, The method comprises the following steps: Step 1: establishing an ordered table, the ordered table comprising a plurality of records corresponding to records in a real-time database, each record of the ordered table comprising a corresponding key and value, each record in the real-time database also comprising a corresponding key and value; the data of the key of the ordered table being a serial number, the data of the value of the ordered table being the data of the key of the real-time database, the value of the ordered table corresponding to the key of the real-time database; the records in the ordered table being arranged in order of the serial number in the key; Step 2: when a record is added in the real-time database, the ordered table also performs an adding record operation, wherein the data of the newly added key of the ordered table is the key of the first record of the ordered table plus the number of records of the ordered table, and the data of the newly added value of the ordered table is the data of the key of the real-time database; Step 3: a maximum record number is configured for the real-time database, when the number of records of the ordered table exceeds the maximum record number, the key of the earliest added record of the real-time database is located through the first record of the ordered table, then the corresponding record in the real-time database is located according to the key value, and the record is deleted, the space is released, and the first record in the ordered table is deleted; Step 4: when the maximum record number is modified to a smaller value, the records exceeding the current maximum record number are deleted from the ordered table in a first-in first-out order when the real-time database is restarted, until the number of records in the ordered table is no longer greater than the current maximum record number, thereby achieving the function of dynamically modifying the storage space of the real-time database.
2. The real-time database storage space control management method of claim 1, wherein: When the ordered table and the real-time database are added and deleted, only one thread can access and edit the real-time database at the same time, and only when the real-time database and the ordered table are simultaneously added or successfully deleted is the operation considered to be successfully completed, otherwise the operation is cancelled, and the ordered table and the real-time database are restored to the state before the operation.
3. The real-time database storage space control management method of claim 2, wherein: When the ordered table and the real-time database do not match, the unmatched records are cleared by traversing the real-time database, thereby ensuring that the records of the ordered table and the real-time database match.
Citation Information
Patent Citations
Method for directly downloading database data to OPC based on RSSQL communication software
CN113076359A
Systems and methods for implementing distributed databases using many-core processors
US20140280375A1