CN117873990A - DDL analysis method, device, equipment and storage medium based on WAL log - Google Patents

DDL analysis method, device, equipment and storage medium based on WAL log Download PDF

Info

Publication number
CN117873990A
CN117873990A CN202410226946.3A CN202410226946A CN117873990A CN 117873990 A CN117873990 A CN 117873990A CN 202410226946 A CN202410226946 A CN 202410226946A CN 117873990 A CN117873990 A CN 117873990A
Authority
CN
China
Prior art keywords
ddl
log
analyzed
type
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410226946.3A
Other languages
Chinese (zh)
Inventor
陶醉
金永顺
杨彬
陈勇铨
胡军擎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Information2 Software Inc
Original Assignee
Shanghai Information2 Software Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Information2 Software Inc filed Critical Shanghai Information2 Software Inc
Priority to CN202410226946.3A priority Critical patent/CN117873990A/en
Publication of CN117873990A publication Critical patent/CN117873990A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention discloses a DDL analysis method, a device, equipment and a storage medium based on WAL logs. The method comprises the following steps: acquiring a log to be analyzed; acquiring zone bit information in a log to be analyzed, and determining a resource type, a processing type and an action object corresponding to the log to be analyzed according to the zone bit information; determining an execution processing function to process the log to be analyzed according to the resource type, the processing type and the action object to obtain an execution result; when the log to be analyzed is processed according to the execution processing function, determining the DDL type of the log to be analyzed which is analyzed currently, and judging whether the log to be analyzed which is analyzed currently meets the preset DDL ending condition or not; and if the current analyzed log to be analyzed meets the preset DDL ending condition, assembling according to the execution result and the DDL type to obtain a DDL analysis result. The method can realize the DDL accurate analysis of the log by judging the end of the DDL type.

Description

DDL analysis method, device, equipment and storage medium based on WAL log
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for DDL parsing based on WAL logs.
Background
Log data is a record of all events occurring on a system, application, or network device. After logging is enabled, the system may automatically generate a log and have a time stamp. The log data provides detailed information such as who is part of the event, when it occurred, where and how it occurred, etc. However, log data is a record of which the specific execution contents cannot be directly known. Therefore, the log data needs to be parsed.
The data definition language (Data Definition Language, DDL) is used to define database objects, such as libraries, tables, columns, and the like. DDL log records are metadata operations generated by data definition statements. The DDL analysis is carried out on the log, so that the understanding of DDL transaction operation can be enhanced, the specific operation record information of the transaction in the log can be obtained, and the method can be used for analyzing the database transaction operation and recovering the data.
However, some databases in the prior art do not support WAL log-based DDL parsing. Therefore, it is desirable to provide a DDL parsing method based on WAL log.
Disclosure of Invention
The invention provides a DDL analysis method, a device, equipment and a storage medium based on a WAL log, which are used for realizing the DDL accurate analysis of the WAL log by judging the end of a DDL type.
According to an aspect of the present invention, there is provided a DDL parsing method based on WAL log, the method including:
acquiring a log to be analyzed;
acquiring zone bit information in the log to be analyzed, and determining a resource type, a processing type and an action object corresponding to the log to be analyzed according to the zone bit information;
determining a corresponding execution processing function to process the log to be analyzed according to the resource type, the processing type and the action object to obtain an execution result;
when the log to be analyzed is processed according to the execution processing function, determining the DDL type of the log to be analyzed which is analyzed currently, and judging whether the log to be analyzed which is analyzed currently meets the preset DDL ending condition;
and if the current analyzed log to be analyzed meets a preset DDL ending condition, assembling according to the execution result and the DDL type to obtain a DDL analysis result.
Optionally, obtaining the log to be parsed includes:
the WAL log generated by the source database is obtained through the stream replication function of the postgres database;
and carrying out format conversion on the WAL log, and carrying out log storage through a zipper method to obtain the log to be analyzed.
Optionally, determining whether the current parsed log to be parsed meets the preset DDL ending condition includes:
judging whether the current analyzed log to be analyzed accords with DDL ending characteristics or not; or judging whether the current parsed log to be parsed has unexpected records.
Optionally, determining whether the current parsed log to be parsed meets the DDL ending feature includes:
if the current analyzed log to be analyzed accords with the DDL ending characteristic and at least two DDL types correspond to the DDL ending characteristic, carrying out data query according to the buffer area corresponding to the at least two DDL types;
and if the data is queried in the target cache region corresponding to the target DDL type, determining that the target DDL type is ended.
Optionally, determining whether the current parsed log to be parsed meets the DDL ending feature includes:
if the DDL ending feature comprises at least two ending sub-features, marking whether the log to be analyzed meets all ending sub-features or not through marking information;
and judging whether the current analyzed log to be analyzed accords with the DDL ending characteristics or not according to the mark information.
Optionally, before determining the DDL type to which the log to be parsed currently belongs, the method further includes:
acquiring a header file of a source database, comparing the header file with a standard file, and determining whether the DDL data structure is changed;
when the DDL data structure is detected to change, the log to be analyzed and the header file are sent to a preset adjustment platform, and the ending condition corresponding to the target DDL type determined by the preset adjustment platform is obtained.
Optionally, the method further comprises:
when detecting that the DDL data structure is unchanged, acquiring a version number of a source database;
and determining the type of the source database according to the version number, and determining the ending condition corresponding to each DDL type according to the characteristic information corresponding to the type of the source database.
According to another aspect of the present invention, there is provided a WAL log-based DDL parsing apparatus, comprising:
the log acquisition module is used for acquiring logs to be analyzed;
the record type determining module is used for acquiring the zone bit information in the log to be analyzed and determining the resource type, the processing type and the action object corresponding to the log to be analyzed according to the zone bit information;
the execution processing function determining module is used for determining that the corresponding execution processing function processes the log to be analyzed to obtain an execution result according to the resource type, the processing type and the action object;
the DDL end determining module is used for determining the DDL type of the current analyzed log to be analyzed when the log to be analyzed is processed according to the execution processing function, and judging whether the current analyzed log to be analyzed meets the preset DDL end condition;
and the DDL analysis result determining module is used for assembling according to the execution result and the DDL type to obtain a DDL analysis result if the current analyzed log to be analyzed meets the preset DDL ending condition.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the WAL log-based DDL resolution method according to any one of the embodiments of the invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement the WAL log-based DDL resolution method according to any one of the embodiments of the present invention when executed.
According to the technical scheme, the log to be analyzed is obtained; acquiring zone bit information in a log to be analyzed, and determining a resource type, a processing type and an action object corresponding to the log to be analyzed according to the zone bit information; determining a corresponding execution processing function to process the log to be analyzed according to the resource type, the processing type and the action object to obtain an execution result; when the log to be analyzed is processed according to the execution processing function, determining the DDL type of the log to be analyzed which is analyzed currently, and judging whether the log to be analyzed which is analyzed currently meets the preset DDL ending condition or not; if the current analyzed log to be analyzed meets the preset DDL ending condition, assembling according to the execution result and the DDL type to obtain a DDL analysis result, solving the problem of DDL analysis based on the WAL log, and realizing the DDL accurate analysis of the log by judging the ending of the DDL type.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for DDL parsing based on WAL logs according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a DDL parsing flow based on WAL logs according to a further embodiment of the present invention;
fig. 3 is a schematic diagram of an application scenario according to a first embodiment of the present invention;
fig. 4 is a schematic structural diagram of a DDL parsing apparatus based on WAL log according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device implementing a WAL log-based DDL parsing method according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a WAL log-based DDL parsing method according to an embodiment of the present invention, where the embodiment is applicable to a case of DDL parsing a log, for example, DDL parsing a WAL log of a postgres database, the method may be performed by a WAL log-based DDL parsing apparatus, and the WAL log-based DDL parsing apparatus may be implemented in hardware and/or software, and the WAL log-based DDL parsing apparatus may be configured in an electronic device. As shown in fig. 1, the method includes:
step 110, obtaining a log to be analyzed.
The log to be parsed is log data that needs DDL parsing. In an optional implementation manner of the embodiment of the present invention, obtaining the log to be parsed includes: the WAL log generated by the source database is obtained through the stream replication function of the postgres database; and carrying out format conversion on the WAL log, and storing the log by a zipper method to obtain the log to be analyzed.
Wherein the postgres database is an open source relational database. The embodiment of the invention can process the pre-written Log (WAL) analysis of various databases taking postgres as prototypes. For example, the technical scheme of the embodiment of the invention can be applied to WAL log analysis of databases such as Postgres, gaussDB, tbase, kingbaseES, lightDB, UXDB and the like.
Fig. 2 is a schematic diagram of a DDL parsing flow based on WAL logs according to a first embodiment of the present invention. As shown in fig. 2, the log stream transferred from the log source can be read by a log reader (XlogReaderState). The WAL log generated by the source library is received by the stream replication function of postgres. And modifying on the basis of the pg source code to obtain a dynamic library which accords with expectations. The received WAL log is converted into a format of a ReorderBufferChange string. Wherein, reorderBufferChange is the minimum unit of the log. Records in the log are stored in a zipper method. With the transaction number as a flag, the ReorderBufferChange string is stored in a different transactionEntry. Wherein, transactionEntry is the parsing unit.
As shown in fig. 2, the zipper storage can be understood as: in the vertical direction, each element represents a TransactionEntry, in order of txid (transaction number); in the horizontal direction, each element represents a ReorderBufferChange, in order of lsn (log sequence number). As shown in fig. 2, one TransactionEntry includes a plurality of reorderbufferchanges. When the type of ReorderBufferChange is commit, this means the end of a transaction. Logic analysis is performed on the entire transaction entry to obtain the DDLs contained by the transaction. The DDL obtained by the analysis can be used downstream.
And 120, acquiring the zone bit information in the log to be analyzed, and determining the resource type, the processing type and the action object corresponding to the log to be analyzed according to the zone bit information.
The obtaining of the flag bit information in the log to be parsed may be determining the flag bit information of each record in the log. ReorderBufferChange can be analyzed sequentially in transactions. The flag bit information may include an RmgrIds flag bit and an info flag bit. Firstly, distinguishing the resource types corresponding to the records according to Rmgrids flag bits; and distinguishing the corresponding subtype, namely the processing type, according to the info flag bit. Different process flows may be performed depending on the type of resource and the type of process.
The flag bit information may be an enumeration parameter. Illustratively, the resource type may be determined from the flag bit information including, but not limited to: heap type and x-act type. The processing type corresponding to the heap type can be determined according to the flag bit information, including but not limited to insertion, modification and deletion. From the flag bit information, it may be determined that the processing type corresponding to the x-act type includes, but is not limited to, commit, abort, and rollback of the transaction.
The action object (RelFileNode) may be a table in a database. For example, the action object may be a system table or a user table in a database, or the like. In log parsing, operations such as insertion, modification or deletion are required to be performed on tables in a database.
And 130, determining a corresponding execution processing function to process the log to be analyzed according to the resource type, the processing type and the action object to obtain an execution result.
The log to be analyzed records a time stamp, an ID identifier, position information and the like of the log. Thus, the execution processing function of the log to be parsed is selected according to the resource type, the processing type and the action object. And processing the action object according to the processing type by executing the processing function to obtain an execution result corresponding to the execution of the log to be analyzed.
And 140, when the log to be analyzed is processed according to the execution processing function, determining the DDL type of the log to be analyzed which is analyzed currently, and judging whether the log to be analyzed which is analyzed currently meets the preset DDL ending condition.
The determining the DDL type to which the log to be parsed belongs may determine whether the current log to be parsed meets the condition of the DDL type according to different processing functions, so as to determine the DDL type to which the log to be parsed belongs.
In an optional implementation manner of the embodiment of the present invention, before determining the DDL type to which the log to be parsed currently belongs, the method further includes: acquiring a header file of a source database, comparing the header file with a standard file, and determining whether the DDL data structure is changed; when the DDL data structure is detected to change, the log to be analyzed and the header file are sent to a preset adjustment platform, and the ending condition corresponding to the target DDL type determined by the preset adjustment platform is obtained.
The header file of the source database may be an ". H" file. In the ". H" file, declaration information, such as library type, may be recorded. The standard file may be a "pt" file. By comparing the header file with the standard file, a variance can be determined, and when a variance exists, a change in the DDL data structure can be determined. Therefore, the log to be analyzed can be sent to a preset adjustment platform. The manager can check the log to be analyzed and the 'h' file in the preset adjustment platform, determine the end condition corresponding to the DDL type, update a stack of DDL types, and ensure the accurate analysis of the DDL.
Illustratively, it is determined for database A that it conforms to the first DDL type when the order of execution is 1- >2- > 3. And for database B, when the execution order is 1- >3- >2, it is determined that it matches the first DDL type. Although both of the first DDL type, they could have different manifestations. By the header file and standard file comparison form provided by the embodiment of the invention, when the DDL type changes in different databases, the DDL can still be accurately analyzed.
It should be noted that, the header file is compared with the standard file to determine whether the DDL data structure is changed, and the method of updating the ending condition corresponding to the target DDL type may be executed in the programming stage.
On the basis of the above embodiment, optionally, the method further includes: when detecting that the DDL data structure is unchanged, acquiring a version number of a source database; and determining the type of the source database according to the version number, and determining the ending condition corresponding to each DDL type according to the characteristic information corresponding to the type of the source database.
Wherein when there is an update to the database version, the source database type may be determined from the version number. And inquiring a system table structure according to the type of the source database, and determining the storage mode of data in the database, thereby determining whether the ending condition of the DDL type is changed or not to update, and realizing the accurate analysis of the DDL.
In DDL parsing, one important point is to accurately judge the start and end of DDL for WAL logs. In an optional implementation manner of the embodiment of the present invention, determining whether the current parsed log to be parsed meets a preset DDL ending condition includes: judging whether the current analyzed log to be analyzed accords with DDL ending characteristics or not; or judging whether the current parsed log to be parsed has unexpected records.
The DDL ending feature may be summarized for different DDL classes. For example, the ending feature of the second DDL type may be to operate on a third table, and when it is determined that the log to be parsed is to operate on a 3 rd table, it may be determined that the second DDL type ends. Unexpected records refer to records that the current DDL type should not occur. For example, for a third DDL type, which represents a build table, the occurrence of insert and update operations in its records may be considered to be records conforming to the build table; however, the delete operation is an unexpected record of the build table. Thus, when a delete occurs in the DDL type of the build table, the end of the build table may be determined.
Specifically, in an optional implementation manner of the embodiment of the present invention, determining whether the log to be parsed currently conforms to the DDL ending feature includes: if the current analyzed log to be analyzed accords with the DDL ending characteristic and at least two DDL types correspond to the DDL ending characteristic, carrying out data query according to the buffer area corresponding to the at least two DDL types; and if the data is queried in the target cache region corresponding to the target DDL type, determining that the target DDL type is ended.
Illustratively, the ending characteristics are the same for both DDL types. For example, for the index and constraint, the DDL ending feature is a log record of an xid 2608 system table operation, and when determining that there is a log record of an xid 2608 system table operation according to the log to be parsed, the data query can be performed in the first buffer area corresponding to the index and the second buffer area corresponding to the constraint respectively. When data is queried in the first buffer area, the index is determined to be ended. And when the data is queried in the second buffer area, determining that the constraint is ended.
Based on the above embodiment, optionally, determining whether the current parsed log to be parsed meets the DDL ending feature includes: if the DDL ending feature comprises at least two ending sub-features, marking whether the log to be analyzed meets all ending sub-features or not through the mark information; and judging whether the current parsed log to be parsed accords with the DDL ending characteristics or not according to the flag information.
Illustratively, for the fourth DDL type, three end sub-features need to be satisfied. After execution of the log corresponding to each end sub-feature is ended, labeling can be performed. For example, after the execution of the log corresponding to the first ending sub-feature ends, the log may be marked according to whether it meets the first ending sub-feature. For example, when the first end sub-feature is satisfied, the symbol is 1, and when the first end sub-feature is not satisfied, the symbol is 0. And the corresponding labeling information is provided for each ending sub-feature. When determining that each accords with each ending sub-feature according to the marking information corresponding to each ending sub-feature, the current analyzed log accords with the DDL ending feature. For example, when the first ending sub-feature, the second ending sub-feature, and the third ending sub-feature are armingly labeled 1, it is determined that the fourth DDL type ending feature is met.
And 150, if the current parsed log to be parsed meets the preset DDL ending condition, splicing according to the execution result and the DDL type to obtain a DDL parsing result.
Whether the WAL log accords with the DDL type ending characteristic is accurately determined by analyzing the WAL log, and whether the DDL is ended is determined. And when the DDL is finished, extracting an execution result related to the DDL type, and selecting a corresponding splicing function to splice to obtain a DDL analysis result. And then sequentially analyzing the next DDL type in the log to be analyzed.
The DDL parsing results include SQL statements and/or Json statements. Wherein, SQL statements can be used for direct loading of the homologous databases. The Json statement may be used for heterogeneous database loading. Specifically, SQL statements and Json statements may be transferred to a unified loading framework replier. The replier selects a corresponding loading driver according to the type of the downstream node, and loads the obtained analysis result, so that the aim of synchronizing data between the same and heterogeneous databases of which the source end is the Postgres database in real time is fulfilled.
According to the technical scheme, the log to be analyzed is obtained; acquiring zone bit information in a log to be analyzed, and determining a resource type, a processing type and an action object corresponding to the log to be analyzed according to the zone bit information; determining a corresponding execution processing function to process the log to be analyzed according to the resource type, the processing type and the action object to obtain an execution result; when the log to be analyzed is processed according to the execution processing function, determining the DDL type of the log to be analyzed which is analyzed currently, and judging whether the log to be analyzed which is analyzed currently meets the preset DDL ending condition or not; if the current analyzed log to be analyzed meets the preset DDL ending condition, assembling according to the execution result and the DDL type to obtain a DDL analysis result, solving the problem of DDL analysis based on the WAL log, and realizing the DDL accurate analysis of the log by judging the ending of the DDL type.
An application scenario provided by the embodiment of the invention can be that data among multiple databases are synchronized in real time, and the backup database redos the analysis result of pgtrack, so that the replier can complete the function. Specifically, fig. 3 is a schematic diagram of an application scenario according to a first embodiment of the present invention. As shown in fig. 3, the WAL log of the Postgres source library may be extracted through pgtrack, the log may be logically parsed through walsiner by adopting the method provided by the embodiment of the present invention, and the obtained SQL and JSON results may be transmitted to the integrated framework replier, so as to load data on the downstream node through the replier. Wherein the downstream nodes include, but are not limited to: message queues, databases (e.g., gaussDB, tbase, kingbaseES, lightDB, UXDB), various texts (e.g., XML, SQL, JSON, TXT, CSV), etc.
Example two
Fig. 4 is a schematic structural diagram of a DDL parsing apparatus based on WAL log according to a second embodiment of the present invention. As shown in fig. 4, the apparatus includes: a log acquisition module 410, a record category determination module 420, an execution processing function determination module 430, a DDL end determination module 440, and a DDL resolution determination module 450. Wherein:
a log obtaining module 410, configured to obtain a log to be parsed;
the record type determining module 420 is configured to obtain flag bit information in the log to be parsed, and determine a resource type, a processing type and an action object corresponding to the log to be parsed according to the flag bit information;
the execution processing function determining module 430 is configured to determine, according to the resource type, the processing type, and the action object, that the corresponding execution processing function processes the log to be parsed to obtain an execution result;
the DDL end determining module 440 is configured to determine a DDL type to which the currently parsed log to be parsed belongs when the log to be parsed is processed according to the execution processing function, and determine whether the currently parsed log to be parsed meets a preset DDL end condition;
and the DDL analysis result determining module 450 is configured to assemble according to the execution result and the DDL type to obtain a DDL analysis result if the currently analyzed log to be analyzed meets a preset DDL ending condition.
Optionally, the log obtaining module 410 includes:
the log acquisition unit is used for acquiring WAL logs generated by the source database through the stream replication function of the postgres database;
the log storage unit is used for carrying out format conversion on the WAL log and carrying out log storage through a zipper method to obtain the log to be analyzed.
Alternatively, the DDL end determination module 440,
the DDL end determining unit is used for judging whether the current analyzed log to be analyzed accords with the DDL end characteristics; or judging whether the current parsed log to be parsed has unexpected records.
Optionally, the DDL end determining unit includes:
the data query subunit is used for performing data query according to the buffer area corresponding to at least two DDL types if the current parsed log accords with the DDL ending characteristic and the at least two DDL types correspond to the DDL ending characteristic;
and the first DDL end determining subunit is used for determining that the target DDL type is ended if the data is queried in the target cache area corresponding to the target DDL type.
Optionally, the DDL end determining unit includes:
the marking subunit is used for marking whether the log to be analyzed meets all the ending sub-features or not through the mark information if the DDL ending features comprise at least two ending sub-features;
and the second DDL end determining subunit is used for judging whether the current analyzed log to be analyzed accords with the DDL end characteristics according to the mark information.
Optionally, the device further includes:
the data structure determining module is used for acquiring a header file of the source database before determining the DDL type of the log to be analyzed which is analyzed currently, comparing the header file with a standard file and determining whether the DDL data structure is changed or not;
and the DDL condition determining module is used for sending the log to be analyzed and the header file to a preset adjusting platform when detecting that the DDL data structure changes, and acquiring the condition corresponding to the target DDL type determined by the preset adjusting platform.
Optionally, the device further includes:
the DDL condition acquisition module is used for acquiring the version number of the source database when detecting that the DDL data structure is not changed;
and determining the type of the source database according to the version number, and determining the ending condition corresponding to each DDL type according to the characteristic information corresponding to the type of the source database.
The DDL analysis device based on the WAL log provided by the embodiment of the invention can execute the DDL analysis method based on the WAL log provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example III
Fig. 5 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 5, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the WAL log-based DDL parsing method.
In some embodiments, the WAL log-based DDL parsing method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the WAL log-based DDL parsing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the WAL log-based DDL parsing method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A WAL log-based DDL parsing method, the method comprising:
acquiring a log to be analyzed;
acquiring zone bit information in the log to be analyzed, and determining a resource type, a processing type and an action object corresponding to the log to be analyzed according to the zone bit information;
determining a corresponding execution processing function to process the log to be analyzed according to the resource type, the processing type and the action object to obtain an execution result;
when the log to be analyzed is processed according to the execution processing function, determining the DDL type of the log to be analyzed which is analyzed currently, and judging whether the log to be analyzed which is analyzed currently meets the preset DDL ending condition;
and if the current analyzed log to be analyzed meets a preset DDL ending condition, assembling according to the execution result and the DDL type to obtain a DDL analysis result.
2. The method of claim 1, wherein obtaining the log to be parsed comprises:
the WAL log generated by the source database is obtained through the stream replication function of the postgres database;
and carrying out format conversion on the WAL log, and carrying out log storage through a zipper method to obtain the log to be analyzed.
3. The method of claim 1, wherein determining whether the currently parsed log to be parsed meets a preset DDL ending condition comprises:
judging whether the current analyzed log to be analyzed accords with DDL ending characteristics or not; or judging whether the current parsed log to be parsed has unexpected records.
4. The method of claim 3, wherein determining whether the currently parsed log to be parsed meets DDL finish features comprises:
if the current analyzed log to be analyzed accords with the DDL ending characteristic and at least two DDL types correspond to the DDL ending characteristic, carrying out data query according to the buffer area corresponding to the at least two DDL types;
and if the data is queried in the target cache region corresponding to the target DDL type, determining that the target DDL type is ended.
5. The method of claim 3, wherein determining whether the currently parsed log to be parsed meets DDL finish features comprises:
if the DDL ending feature comprises at least two ending sub-features, marking whether the log to be analyzed meets all ending sub-features or not through marking information;
and judging whether the current analyzed log to be analyzed accords with the DDL ending characteristics or not according to the mark information.
6. The method of claim 1, further comprising, prior to determining the DDL type to which the currently parsed log belongs:
acquiring a header file of a source database, comparing the header file with a standard file, and determining whether the DDL data structure is changed;
when the DDL data structure is detected to change, the log to be analyzed and the header file are sent to a preset adjustment platform, and the ending condition corresponding to the target DDL type determined by the preset adjustment platform is obtained.
7. The method as recited in claim 6, further comprising:
when detecting that the DDL data structure is unchanged, acquiring a version number of a source database;
and determining the type of the source database according to the version number, and determining the ending condition corresponding to each DDL type according to the characteristic information corresponding to the type of the source database.
8. A WAL log-based DDL resolution apparatus comprising:
the log acquisition module is used for acquiring logs to be analyzed;
the record type determining module is used for acquiring the zone bit information in the log to be analyzed and determining the resource type, the processing type and the action object corresponding to the log to be analyzed according to the zone bit information;
the execution processing function determining module is used for determining that the corresponding execution processing function processes the log to be analyzed to obtain an execution result according to the resource type, the processing type and the action object;
the DDL end determining module is used for determining the DDL type of the current analyzed log to be analyzed when the log to be analyzed is processed according to the execution processing function, and judging whether the current analyzed log to be analyzed meets the preset DDL end condition;
and the DDL analysis result determining module is used for assembling according to the execution result and the DDL type to obtain a DDL analysis result if the current analyzed log to be analyzed meets the preset DDL ending condition.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the WAL log-based DDL resolution method of any of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the WAL log-based DDL resolution method of any one of claims 1-7 when executed.
CN202410226946.3A 2024-02-29 2024-02-29 DDL analysis method, device, equipment and storage medium based on WAL log Pending CN117873990A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410226946.3A CN117873990A (en) 2024-02-29 2024-02-29 DDL analysis method, device, equipment and storage medium based on WAL log

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410226946.3A CN117873990A (en) 2024-02-29 2024-02-29 DDL analysis method, device, equipment and storage medium based on WAL log

Publications (1)

Publication Number Publication Date
CN117873990A true CN117873990A (en) 2024-04-12

Family

ID=90584710

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410226946.3A Pending CN117873990A (en) 2024-02-29 2024-02-29 DDL analysis method, device, equipment and storage medium based on WAL log

Country Status (1)

Country Link
CN (1) CN117873990A (en)

Similar Documents

Publication Publication Date Title
US7822710B1 (en) System and method for data collection
US11645179B2 (en) Method and apparatus of monitoring interface performance of distributed application, device and storage medium
CN115599769A (en) Data migration method and device, electronic equipment and storage medium
US20230012642A1 (en) Method and device for snapshotting metadata, and storage medium
CN115617888A (en) Data import method, device, equipment, storage medium and product
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN114168119B (en) Code file editing method, device, electronic equipment and storage medium
CN116028517A (en) Fusion database system and electronic equipment
CN115618777A (en) File generation method, device, equipment and storage medium
CN117873990A (en) DDL analysis method, device, equipment and storage medium based on WAL log
CN114676054A (en) Test data generation method, device, equipment, medium and product
CN118012897A (en) Heterogeneous database grammar conversion method, device, equipment and storage medium
CN115981657A (en) Code generation method and device, electronic equipment and readable medium
CN114860312A (en) Mobile terminal adaptation method, device, equipment and medium based on credit business
CN118312497A (en) Database migration method, device, equipment, storage medium and product
CN114416881A (en) Real-time synchronization method, device, equipment and medium for multi-source data
CN116841982A (en) Database migration method, device, equipment, storage medium and program product
CN117171165A (en) Database falling method and device, electronic equipment and storage medium
CN115495368A (en) Data testing method and device and electronic equipment
CN117251196A (en) Data maintenance method, device, equipment and storage medium
CN117421322A (en) Data reading method, device, equipment and medium
CN115454977A (en) Data migration method, device, equipment and storage medium
CN117668113A (en) Data synchronization method, device, equipment and medium
CN117251167A (en) Software bill of materials construction method, device, equipment and medium
CN115756575A (en) Submission record acquisition method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination