CN116841970A - Flow dyeing method and device for database, electronic device and storage medium - Google Patents

Flow dyeing method and device for database, electronic device and storage medium Download PDF

Info

Publication number
CN116841970A
CN116841970A CN202210303122.2A CN202210303122A CN116841970A CN 116841970 A CN116841970 A CN 116841970A CN 202210303122 A CN202210303122 A CN 202210303122A CN 116841970 A CN116841970 A CN 116841970A
Authority
CN
China
Prior art keywords
operation request
database
flow
traffic
target database
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
CN202210303122.2A
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.)
Hangzhou Youzan Technology Co ltd
Original Assignee
Hangzhou Youzan Technology Co ltd
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 Hangzhou Youzan Technology Co ltd filed Critical Hangzhou Youzan Technology Co ltd
Priority to CN202210303122.2A priority Critical patent/CN116841970A/en
Publication of CN116841970A publication Critical patent/CN116841970A/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/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a flow dyeing method, a device, an electronic device and a storage medium of a database, wherein the method comprises the following steps: confirming that the log of the target database is in log opening; and confirming that the data transmission service is in subscription to the change event of the target database; determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol; transmitting the generated second operation request to a target database; after subscribing to the change generated by the target database based on the second operation request, the data transmission service acquires the second operation request in the change event from the log of the target database; and determines a corresponding traffic identification. The application solves the problems of high realization complexity and serious performance loss of the display transaction needing to be added; under the condition that the support database is used as a change source, the log corresponding to the second operation request is utilized to pass through the flow identification in the second operation request, so that the flow identification can be reserved.

Description

Flow dyeing method and device for database, electronic device and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method and an apparatus for traffic staining of a database, an electronic device, and a storage medium.
Background
The flow dyeing means that corresponding flow dyeing rules are set according to a flow protocol, the designated flow is dyed and marked, and the mark is carried in the whole call chain. Specific traffic can be tracked and routed through the dye traffic. The traffic dyeing has wide application in micro-services, and can be used in the scenes related to databases, such as gray level distribution, link isolation, unitization, data migration and the like.
Because the database log does not record the source of the request, the presence of asynchronous data transfer mode in the event of a database change as the trigger source can result in the loss of traffic markings in the source of the request. Therefore, the current flow dyeing scheme of the database is to add a marking table for recording flow marks; all data modifications involved in the database require opening the transaction to synchronize the tag table, and inserting a statement record into the transaction to the newly added table for recording the flow tag. The disadvantage of this approach is that the display transaction needs to be added, the implementation complexity is high, and the business intrusion is required, resulting in serious performance loss.
Aiming at the problems that display transactions need to be added in the related technology, the implementation complexity is high, business invasion is needed, the performance loss is serious, and no effective solution is proposed at present.
Disclosure of Invention
In this embodiment, a method, an apparatus, an electronic device, and a storage medium for traffic staining of a database are provided, so as to solve the problems that in the related art, display transactions need to be added, implementation complexity is high, and business invasion is needed, resulting in serious performance loss.
In a first aspect, in this embodiment, there is provided a method for traffic staining of a database, including:
confirming that the log of the target database is in log opening; and confirming that the data transmission service is in subscription to a change event of the target database;
determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol;
generating a second operation request according to the flow identification and the first operation request, and transmitting the second operation request to the target database;
after subscribing to the change generated by the target database based on the second operation request, the data transmission service acquires the second operation request in the change event from the log of the target database; and determining the corresponding flow identification based on the second operation request.
In some of these embodiments, the method further comprises:
receiving the second operation request in the target database, and changing target data in the target database based on the second operation request to obtain target change data;
based on the starting state of the log, automatically recording a change event by the log in the target database; the change event includes the target change data and the second operation request.
In some of these embodiments, the predefined traffic protocol includes identification format information, type information, bearer information, and processing policies.
In some embodiments, the generating a second operation request according to the traffic identification and the first operation request includes:
and splicing the flow identification into the annotation of the first operation request to generate a second operation request.
In some embodiments, the determining, based on the predefined traffic protocol, a traffic identification corresponding to the initiated first operation request includes:
initiating a first operation request;
acquiring current service requirements;
and generating a flow identifier corresponding to the first operation request according to the service requirement based on the predefined flow protocol.
In some embodiments, the determining, based on the second operation request, the corresponding traffic identification includes:
and analyzing the annotation of the second operation request to analyze the flow identification from the annotation of the second operation request.
In some of these embodiments, the method further comprises:
acquiring the predefined traffic protocol in the data transmission service;
and after determining the corresponding flow identification, carrying out classification processing according to the predefined flow protocol and the flow identification.
In some embodiments, the classifying according to the predefined traffic protocol and the traffic identifier includes:
and according to the predefined flow protocol and the environment source information in the flow identifier, returning the change event route in the target database to the original environment so as to realize environment isolation.
In some embodiments, the classifying according to the predefined traffic protocol and the traffic identifier includes:
and shielding the change event in the target database according to the predefined flow protocol and shielding modification information in the flow identifier so as to realize shielding specific modification.
In a second aspect, in this embodiment, there is provided a flow staining apparatus for a database, including: the system comprises a state confirmation module, a determination module, a generation module and a processing module;
the state confirmation module is used for confirming that the target database is in a change release state and a log opening state; and confirming that the data transmission service is in a changed subscription state to the target database;
the determining module is used for determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol;
the generating module is used for generating a second operation request according to the flow identification and the first operation request and transmitting the second operation request to the target database;
the processing module is used for acquiring a second operation request in the change event from a log of the target database after the data transmission service subscribes to the change generated by the target database based on the second operation request; and determining the corresponding flow identification based on the second operation request.
In a third aspect, in this embodiment, there is provided an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the method for traffic staining of the database according to the first aspect.
In a fourth aspect, in this embodiment, there is provided a storage medium having stored thereon a computer program which, when executed by a processor, implements the method for traffic staining of a database according to the first aspect described above.
Compared with the related art, the flow staining method, the device, the electronic device and the storage medium of the database provided in the embodiment are started by confirming that the log of the target database is in the log; and confirming that the data transmission service is in subscription to the change event of the target database; determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol; generating a second operation request according to the flow identification and the first operation request, and transmitting the second operation request to a target database; after subscribing to the change generated by the target database based on the second operation request, the data transmission service acquires the second operation request in the change event from the log of the target database; and based on the second operation request, the corresponding flow identification is determined, so that the problems that the display transaction is required to be added, the implementation complexity is high, the service invasion is required, and the performance loss is serious in the related art are solved, and under the condition that the support database is used as a change source, the flow identification in the second operation request is transmitted through the log corresponding to the second operation request, so that the flow identification can be reserved.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the other features, objects, and advantages of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute a limitation on the application. In the drawings:
FIG. 1 is a block diagram of a database flow staining system according to one embodiment of the present application;
FIG. 2 is a flow chart of a method for traffic staining of a database according to an embodiment of the present application;
fig. 3 is a flowchart of step S220 in fig. 2;
FIG. 4 is a flow chart of a database flow staining method according to an embodiment of the present application applied in environmental isolation;
FIG. 5 is a flow chart of a database flow dyeing method applied in shielding specific modification according to an embodiment of the present application;
fig. 6 is a block diagram of a flow rate dyeing apparatus of a database according to an embodiment of the present application.
In the figure: 10. a client; 20. a database; 30. a data transmission service; 210. a status confirmation module; 220. a determining module; 230. a generating module; 240. and a processing module.
Detailed Description
The present application will be described and illustrated with reference to the accompanying drawings and examples for a clearer understanding of the objects, technical solutions and advantages of the present application.
Unless defined otherwise, technical or scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terms "a," "an," "the," "these" and similar terms in this application are not intended to be limiting in number, but may be singular or plural. The terms "comprising," "including," "having," and any variations thereof, as used herein, are intended to encompass non-exclusive inclusion; for example, a process, method, and system, article, or apparatus that comprises a list of steps or modules (units) is not limited to the list of steps or modules (units), but may include other steps or modules (units) not listed or inherent to such process, method, article, or apparatus. The terms "connected," "coupled," and the like in this disclosure are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as used herein means two or more. "and/or" describes an association relationship of an association object, meaning that there may be three relationships, e.g., "a and/or B" may mean: a exists alone, A and B exist together, and B exists alone. Typically, the character "/" indicates that the associated object is an "or" relationship. The terms "first," "second," "third," and the like, as referred to in this disclosure, merely distinguish similar objects and do not represent a particular ordering for objects.
The method embodiments provided in this embodiment may be applicable to a flow staining system of a database. As shown in fig. 1: the system includes a client 10, a database 20, and a data transmission service 30; the client 10 is connected to the database 20 and the data transmission service 30, respectively, and the data transmission service 30 simulates itself as a slave library and is connected to the database 20 in a manner of subscribing to the database.
Wherein, the confirmation that the log of the target database 20 is at log on can be performed in the client 10; and confirms that the data transfer service 30 is subscribed to the change event of the target database; determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol; generating a second operation request according to the flow identification and the first operation request, transmitting the second operation request to a target database, and the like. Specifically, the client 10: may be a mobile terminal, a fixed terminal, or a portable terminal, such as a mobile handset, a site, a unit, a device, a multimedia computer, a multimedia tablet, an internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a Personal Communications System (PCS) device, a personal navigation device, a Personal Digital Assistant (PDA), an audio/video player, a digital camera/camcorder, a positioning device, a television receiver, a radio broadcast receiver, an electronic book device, a game device, or any combination thereof, including the accessories and peripherals of these devices, or any combination thereof.
Where the target database refers to the database 20 of the current target. Receiving a second operation request in the target database, and changing target data in the target database based on the second operation request to obtain target change data; based on the starting state of the log, the log in the target database automatically records a change event; the change event comprises the steps of target change data, a second operation request and the like. In particular, database 20 is a "repository" that organizes, stores, and manages data according to a data structure. Is a collection of large amounts of data stored in a computer for a long period of time, organized, sharable, and uniformly managed. The database 20 is classified into a relational database and a non-relational database by type. The relation type database can intuitively reflect the relation among entities in a storage format. Relational databases are similar to common tables, and there are many complex relationships between tables in relational databases. A common relational database is MySQL, sqlServer. A non-relational database refers to a distributed, non-relational data storage system that is not guaranteed to follow the ACID principle. Such as MongoDB, redis, memcache, etc.
Wherein the data transfer service 30 (Data Transmission Service, DTS): the second operation request in the change event may be obtained from the log of the target database after the data transmission service 30 subscribes to the change generated by the target database based on the second operation request; and determining a corresponding flow identifier based on the second operation request, and the like. Specifically, the data transmission service 30 is a database data transmission service 30 that provides data migration, data synchronization, and data subscription. The data transfer service 30 includes two core components: database subscription components and Message Queues (MQs). The database subscription component generally simulates the database subscription component itself as a slave library, subscribes to change events occurring in a target database, and then sends the change events to a message queue for business indirect subscription database change after internal processing. The message queue provides asynchronous communication capability, and has the capability of ensuring that the message is not lost and fails to be retransmitted.
The method provided in the present embodiment may be performed at the client 10, the data transmission service 30; or in a terminal, computer or similar computing device of the client 10, data transmission service 30 and database 20. Such as on a terminal, which may include one or more processors and memory for storing data, where the processors may include, but are not limited to, a microprocessor MCU or a programmable logic device FPGA or the like. The terminal may further include a transmission device for a communication function and an input-output device. The terminal may also have different configurations, such as having multiple processors, etc.
The memory may be used to store a computer program, for example, a software program of application software and a module, such as a computer program corresponding to a traffic dyeing method of a database in the present embodiment, and the processor executes the computer program stored in the memory, thereby performing various functional applications and data processing, that is, implementing the above-described method. The memory may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory. In some examples, the memory may further include memory remotely located with respect to the processor, the remote memory being connectable to the terminal through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device is used for receiving or transmitting data via a network. The network includes a wireless network provided by a communication provider of the terminal. In one example, the transmission device includes a network adapter (Network Interface Controller, simply referred to as NIC) that can connect to other network devices through the base station to communicate with the internet. In one example, the transmission device may be a Radio Frequency (RF) module, which is used to communicate with the internet wirelessly.
Currently, the general flow of changing the database as the trigger source is: changing target data in a database based on a request of a service; executing the request to modify the target data, logging the corresponding change events (transactions and modifications made to the database by each transaction); a database subscription component of the data transmission service 30 (DTS) actively listens for log changes corresponding to the database (corresponding to MySQL database is a listening log binlog), and delivers the change event to a Message Queue (MQ) after processing; the downstream service completes the service scenario by consuming the messages of the MQ. Advantages of database changes as trigger sources include: ensuring change event transactional, service asynchronization, service decoupling and the like, but only recording the transaction (comprising the request) and the modification of each transaction to the database due to the log of the database, and not recording the source of the request; this asynchronous approach can result in a loss of traffic label.
Then the flow dyeing is realized by newly adding the flow label for recording the label table of the flow label, and all the related data modification in the database is required, so that the transaction is started to synchronize the label table; and inserts a statement record into the new table for recording the flow label. The disadvantage of this approach is that the display transaction needs to be added, the implementation complexity is high, and the business intrusion is required, resulting in serious performance loss.
Based on the above reasons, the present application aims to utilize the log corresponding to the second operation request to transparently transmit the flow identifier in the second operation request in the scenario that the support database is used as a change source, so that the flow identifier can be reserved; on the premise of no business invasion, the second operation request is utilized to realize flow dyeing, and the aim of preventing serious performance loss is fulfilled.
The overall scheme of the application is described below:
in this embodiment, a flow rate dyeing method of a database is provided, and fig. 2 is a flowchart of the flow rate dyeing method of the database in this embodiment, as shown in fig. 2, where the flowchart includes the following steps:
step S210, confirming that the log of the target database is in log opening; and confirming that the data transmission service is in subscription to the change event of the target database;
specifically, the database itself has a log, and after the log is opened, a change event is recorded. A change event refers to all transactions (including requests) and modifications made to the database by each transaction. For example, the mode of the log may be set to a row mode to cause the log to be turned on; the log opening arrangement is different for different databases, and is not exemplified here.
The data transmission service is in subscription of the change event of the target database, namely the database subscription component in the data transmission service simulates the database subscription component to be a slave database, so that the change event of the target database can be actively monitored; i.e., a change event that occurs to the subscription target database. If the above steps are performed in the client, a service request may be initiated in the client, confirming that the data transfer service is subscribed to the change event of the target database based on a return message of the service request. Of course, it is also possible to confirm in other ways for different databases that the data transfer service is subscribed to the change event of the target database.
Step S220, determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol;
in particular, the traffic protocol may be predefined in the client. Traffic protocols include, but are not limited to, identification format information, type information, bearer information, and processing policies. The identification format information is arranged according to the sequence of the type information, the bearing information and the processing strategy, and the identification format information starts with/and ends with characters. Such as: the identification format information is/type information: carrying information: treatment strategy. Wherein, the type information can be aa_tag; various types may be defined, such as aa_ctl as a control type; aa_tag is defined as the source context. Wherein aa may be replaced by other characters. The bearer information may be context, pre, etc. and has a format of CSV/JSON/Base64, etc. The processing policy is a processing specification corresponding to the type information, for example: for example, aa_tag type is used to define traffic source environment for traffic isolation scenario; aa_ctl is used to define the control type, to control whether database changes are ignored, etc. In other embodiments, the predefined traffic protocol may not contain a processing policy, that is, the processing policy may be singled out to generate a file for use. Such as: in the client, the traffic protocol is transmitted to the data transmission service together with the processing policy by means of the transmission protocol.
Specific traffic protocols (except processing policies) in different formats are illustrated below.
JSON format: aa_tag { "env": "pre", "user": "xxx", "app": "yy" }/;
CSV format: aa_tag: pre, xxx, yyy/; the format header is env, user, app, equivalent to JSON format described above.
Base64 format: aa_tag: chjlhh 4eCx5eXk =/; the Base64 format is generally used to define complex structures, or binary data.
Then, based on the predefined flow protocol, in combination with the current service requirement, the flow identifier corresponding to the initiated first operation request may be determined. Such as: the current business requirement of the first operation request is the flow dyeing of the test environment; the flow mark is: aa_tag: pre/. Wherein aa_tag is used for identifying the traffic environment, and pre indicates that the current traffic source is the test environment.
Step S230, generating a second operation request according to the flow identification and the first operation request, and transmitting the second operation request to a target database;
specifically, the first operation request refers to a specific operation request which is actively initiated by the client and aims at target data in the target database. Such as: change, delete, isolate, etc. Splicing or assembling the flow marks on the basis of the first operation request to generate a second operation request; so that the second operation request includes the traffic identification. The application transmits the second operation request to the target database so that the target server can perform subsequent processing based on the second operation request.
Step S240, after subscribing to the change generated by the target database based on the second operation request, the data transmission service acquires the second operation request in the change event from the log of the target database; and determining a corresponding flow identification based on the second operation request.
Specifically, since the data transfer service is a slave library that is a target database, it can monitor changes in the log of the target database. Therefore, the user can subscribe to the change generated by the target database based on the second operation request to obtain a change event of the log of the target database; analyzing the change event to obtain a second operation request in the change event; finally, analyzing the corresponding flow identification from the second operation request; therefore, on the premise of no business invasion, the flow dyeing is realized by using the second operation request. In the scenario where the support database is used as the change source, the flow identification in the second operation request is transmitted through the log corresponding to the second operation request, so that the flow identification can be retained.
Through the steps, the second operation request comprising the flow identification is taken as a request object of the change in the target database; automatically recording change events after the log is opened, and combining subscription services of the data transmission service; under the scene of supporting the database as a change source, the flow identification in the second operation request is transmitted through the log corresponding to the second operation request, so that the flow identification can be reserved; the method solves the problems that the display transaction needs to be added, the implementation complexity is high, the business invasion is needed, and the performance loss is serious in the related technology.
In some embodiments, the method for traffic staining of the database further comprises the steps of:
receiving a second operation request in the target database, and changing target data in the target database based on the second operation request to obtain target change data;
based on the starting state of the log, the log in the target database automatically records a change event; the change event includes target change data and a second operation request.
Specifically, the target database receives the second operation request, and changes the target data in the target database based on the second operation request, for example: the second operation request is to change the target data 1 to 2; then the target change data is 2. At this time, based on the open state of the log, the log automatically records the change event, including recording the second operation request and the target change data. And the database is executed according to the normal flow based on the second operation request, so that no extra transaction is needed to be added, and the normal operation of the database is ensured.
In some of these embodiments, generating the second operation request in step S230 according to the traffic identification and the first operation request includes the steps of:
The traffic identification is spliced into the annotation of the first operation request, generating a second operation request.
In particular, annotations are explanations and illustrations of the code, which generally follow the code. Each operation request has a corresponding annotation. Such as: for a first operation request delete from tb where id =1; flow label is/aa_tag; the second operation request after the concatenation of the traffic marks is/aa_tag: pre/delete from tb where id =1. In this embodiment, the flow identifier is spliced to the comment of the first operation request, so that the generated second operation request can also not affect subsequent processing on the premise of containing the flow identifier; and the annotation of the second operation request is communicated with the second operation request. As long as the server has the annotation function, the steps can be adopted, so that the stability and the transmission efficiency in the transmission process can be improved.
Of course, if the flow identifier is spliced in the annotation, when determining the corresponding flow identifier in the second operation request in the data transmission service, the annotation of the second operation request can be directly analyzed to analyze the flow identifier from the annotation of the second operation request, so that the processing efficiency is improved; and the accuracy of the analysis result can be ensured.
In some of these embodiments, as shown in fig. 3, step S220 includes the steps of:
step S221, a first operation request is initiated;
step S222, obtaining the current service requirement;
step S223, based on the predefined flow protocol, generating a flow identification corresponding to the first operation request according to the service requirement.
Specifically, a first operation request is normally initiated in the client; current traffic requirements refer to traffic requirements matching the first operation request including, but not limited to, traffic isolation, mask specific modifications, traffic source identification, etc. The service requirement can be defined by a user or by a preset service policy. Then based on predefined flow protocol, in combination with current service requirement, flow identification corresponding to the first operation request can be produced. Generally, on the premise of traffic dyeing, each first operation request has a corresponding traffic identifier.
In some embodiments, the method for traffic staining of the database further comprises the following steps:
in the data transmission service, a predefined flow protocol is acquired;
after the corresponding flow identification is determined, classification processing is performed according to a predefined flow protocol and the flow identification.
In particular, the data transfer service may obtain the predefined traffic protocol in the client by means of a transfer protocol or a software development kit (Software Development Kit, SDK) or the like. After the corresponding flow identification is determined, specific classification processing can be performed according to the predefined flow protocol and flow representation, so that the method and the device are applicable to application scenes such as gray level release, link isolation, unitization and data migration.
The following illustrates the different classification processes, so that the purpose of applying the flow staining method of the database to different scenes can be achieved.
Application of traffic staining for databases in environmental isolation: as shown in fig. 4, includes a test environment test-env and a standard environment std-env; the test environment test-env comprises a first client server 'and a first listener Listener'; the standard environment std-env comprises a second client server, a database MySQL, a data transfer service DTS and a second listener Listener.
The flow dyeing method comprises the following steps:
looking at using command show variables like 'binlog_rows_query_log_events', returning ON indicates that the log is open, otherwise it may be open by set GLOBAL binlog _rows_query_log_events=1 command; thereby confirming that the log of the database MySQL is on. And confirms that the data transmission service DTS is in subscription to a change event of the database MySQL;
Predefined traffic protocols and aa_tag are defined for identifying traffic contexts, pre indicates that the current traffic source is the test context.
Determining, based on the predefined flow protocol, a flow identification (/ aa_tag: pre /); the determined flow protocol is/aa_tag;
intercepting a first operation request (SQL sentence) through an internetwor function of MyBatis plug in, and splicing a flow identifier in the annotation of the first operation request (SQL sentence) in the internept method; transmitting the second operation request to the target database;
first operation request (SQL statement): update table_name set val= 'yyy' where id=1;
a second operation request: aa_tag pre/update table_name set val= 'yyy' where id=1;
the data transmission service DTS subscribes to a change event binlog of the database MySQL, analyzes a second operation request from the change event binlog, and determines a corresponding flow identifier/aa_tag: pre from the second operation request. Such as: from the second operation request to the first operation request (SQL statement)/aa_tag: pre/update table_name_name=1, the traffic identifier/aa_tag: pre is extracted, where the type is aa_tag, and the content is pre indicating that the traffic comes from the test environment.
Based on the application, the classification processing is performed according to the predefined flow protocol and the flow identification, and the method comprises the following steps:
and according to the predefined flow protocol and the environment source information in the flow identification, returning the route of the change event in the target database to the original environment so as to realize environment isolation.
Specifically, because pre indicates that the traffic is from the test environment, that is, the traffic identifier has environment source information, it can be determined that the change operation of the target data is from the test environment; such as a first operation request source test environment test-env; since the traffic identifier has the environment source information, the data transmission service DTS routes the change event back to the original environment (first listener Listener') according to the predefined traffic protocol and the environment source information in the traffic identifier, thereby implementing the environment isolation function. When traffic staining of the database is not achieved, the change event subscribed to by the data transfer service DTS cannot distinguish whether the trigger source is a test environment or a standard environment. And the subscription can ensure the transactional property, and can subscribe to the changed data, thereby achieving the continuity of the flow.
Application of traffic staining for databases in masking specific modifications: as shown in fig. 5, the third Client server, the fourth Client, the database MySQL, the data transfer service DTS, and the third listener Listener are included.
The flow staining method has the steps similar to the flow of the application of flow staining for databases in environmental isolation, except that: in this application, the traffic is identified as: (/. Aa_ctl: ignore /); the flow protocol aa_ctl is used to identify the control type, ignore indicates that the change is ignored.
First operation request (SQL statement): update table_name set val= 'yyy' where id=1;
a second operation request: (/ aa_ctl: ignore_update table_name set val= 'yyy' whereid=1;
the data transmission service DTS subscribes to a change event binlog of the database MySQL, analyzes a second operation request from the change event binlog, and determines a corresponding flow identifier/aa_ctl: ignore/' from the second operation request. Such as: resolving from the second operation request to the first operation request (SQL statement)/aa_ctl: ignow_table_name val= 'yyy' where id=1, and extracting the traffic identifier/aa_ctl: ignow/, where the type aa_ctl represents control and the content is ignow represents ignore change.
Based on the application, the classification processing is performed according to the predefined flow protocol and the flow identification, and the method comprises the following steps:
and shielding the change event in the target database according to the predefined flow protocol and shielding modification information in the flow identification so as to realize shielding specific modification.
Specifically, the database subscription component subscribes to change events occurring in the target database, as the traffic is identified as/aa_ctl: ignore/, where type aa_ctl represents control and content ignore represents ignore changes. The change event is not sent to the message queue and is thus masked from being perceived by the third listener Listener. Such as: the process of manually repairing data can avoid side effects caused by repairing.
It should be noted that the steps illustrated in the above-described flow or flow diagrams of the figures may be performed in a computer system, such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flow diagrams, in some cases, the steps illustrated or described may be performed in an order other than that illustrated herein.
In this embodiment, a flow rate dyeing device for a database is further provided, and the device is used to implement the foregoing embodiments and preferred embodiments, and will not be described again. The terms "module," "unit," "sub-unit," and the like as used below may refer to a combination of software and/or hardware that performs a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementations in hardware, or a combination of software and hardware, are also possible and contemplated.
Fig. 6 is a block diagram of the flow rate staining apparatus of the database of the embodiment, and as shown in fig. 6, the apparatus includes: a status validation module 210, a determination module 220, a generation module 230, and a processing module 240;
a state confirmation module 210, configured to confirm that the target database is in a change release state and a log open state; confirming that the data transmission service is in a changed subscription state to the target database;
a determining module 220, configured to determine, based on a predefined traffic protocol, a traffic identifier corresponding to the initiated first operation request;
the generating module 230 is configured to generate a second operation request according to the flow identifier and the first operation request, and transmit the second operation request to the target database;
the processing module 240 is configured to obtain, after the data transmission service subscribes to the change generated by the target database based on the second operation request, the second operation request in the change event from the log of the target database; and determining a corresponding flow identification based on the second operation request.
By the device, the second operation request comprising the flow identifier is taken as a request object of the change in the target database; automatically recording change events after the log is opened, and combining subscription services of the data transmission service; under the scene of supporting the database as a change source, the flow identification in the second operation request is transmitted through the log corresponding to the second operation request, so that the flow identification can be reserved; the method solves the problems that the display transaction needs to be added, the implementation complexity is high, the business invasion is needed, and the performance loss is serious in the related technology.
In some of these embodiments, on the basis of fig. 6, a modification processing module is further included;
the change processing module is used for receiving a second operation request in the target database, and changing target data in the target database based on the second operation request to obtain target change data;
based on the starting state of the log, the log in the target database automatically records a change event; the change event includes target change data and a second operation request.
In some of these embodiments, the predefined traffic protocol includes identification format information, type information, bearer information, and processing policies.
In some of these embodiments, the generating module 230 is further configured to splice the traffic identifier into an annotation of the first operation request, and generate a second operation request.
In some embodiments, the determining module 220 is further configured to initiate a first operation request;
acquiring current service requirements;
based on a predefined flow protocol, a flow identifier corresponding to the first operation request is generated according to the service requirement.
In some embodiments, the processing module 240 is further configured to parse the annotation of the second operation request to parse the traffic identifier from the annotation of the second operation request.
In some of these embodiments, on the basis of fig. 6, a classification processing module is further included;
the classification processing module is used for acquiring a predefined flow protocol in the data transmission service;
after the corresponding flow identification is determined, classification processing is performed according to a predefined flow protocol and the flow identification.
In some embodiments, the classification processing module is further configured to route the change event in the target database back to the original environment according to the predefined traffic protocol and the environment source information in the traffic identifier, so as to implement the environment isolation.
In some embodiments, the classification processing module is further configured to mask the change event in the target database according to the predefined traffic protocol and the mask modification information in the traffic identifier, so as to implement the mask specific modification.
The above-described respective modules may be functional modules or program modules, and may be implemented by software or hardware. For modules implemented in hardware, the various modules described above may be located in the same processor; or the above modules may be located in different processors in any combination.
There is also provided in this embodiment an electronic device comprising a memory having stored therein a computer program and a processor arranged to run the computer program to perform the steps of any of the method embodiments described above.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, where the transmission device is connected to the processor, and the input/output device is connected to the processor.
Alternatively, in the present embodiment, the above-described processor may be configured to execute the following steps by a computer program:
s1, confirming that a log of a target database is in log opening; and confirming that the data transmission service is in subscription to the change event of the target database;
s2, determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol;
s3, generating a second operation request according to the flow identification and the first operation request, and transmitting the second operation request to a target database;
s4, after the data transmission service subscribes to the change generated by the target database based on the second operation request, the second operation request in the change event is acquired from the log of the target database; and determining a corresponding flow identification based on the second operation request.
It should be noted that, specific examples in this embodiment may refer to examples described in the foregoing embodiments and alternative implementations, and are not described in detail in this embodiment.
In addition, in combination with the flow rate dyeing method of the database provided in the above embodiment, a storage medium may be provided in this embodiment. The storage medium has a computer program stored thereon; the computer program, when executed by a processor, implements the flow staining method of any of the databases of the above embodiments.
It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to be limiting. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure in accordance with the embodiments provided herein.
It is to be understood that the drawings are merely illustrative of some embodiments of the present application and that it is possible for those skilled in the art to adapt the present application to other similar situations without the need for inventive work. In addition, it should be appreciated that while the development effort might be complex and lengthy, it will nevertheless be a routine undertaking of design, fabrication, or manufacture for those of ordinary skill having the benefit of this disclosure, and further having the benefit of this disclosure.
The term "embodiment" in this disclosure means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive. It will be clear or implicitly understood by those of ordinary skill in the art that the embodiments described in the present application can be combined with other embodiments without conflict.
The above examples merely represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the patent claims. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (12)

1. A method for traffic staining of a database, comprising:
confirming that the log of the target database is in log opening; and confirming that the data transmission service is in subscription to a change event of the target database;
Determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol;
generating a second operation request according to the flow identification and the first operation request, and transmitting the second operation request to the target database;
after subscribing to the change generated by the target database based on the second operation request, the data transmission service acquires the second operation request in the change event from the log of the target database; and determining the corresponding flow identification based on the second operation request.
2. The method of traffic staining of the database of claim 1, wherein the method further comprises:
receiving the second operation request in the target database, and changing target data in the target database based on the second operation request to obtain target change data;
based on the starting state of the log, automatically recording a change event by the log in the target database; the change event includes the target change data and the second operation request.
3. The method of traffic coloring of a database according to claim 1, wherein said predefined traffic protocol comprises identification format information, type information, bearer information, and processing policies.
4. A method of traffic staining of a database according to any of claims 1 to 3 wherein the generating a second operation request from the traffic identification and the first operation request comprises:
and splicing the flow identification into the annotation of the first operation request to generate a second operation request.
5. The method of traffic staining of the database of claim 4 wherein the determining the traffic identification corresponding to the initiated first operation request based on the predefined traffic protocol comprises:
initiating a first operation request;
acquiring current service requirements;
and generating a flow identifier corresponding to the first operation request according to the service requirement based on the predefined flow protocol.
6. The method of traffic staining of the database of claim 4 wherein the determining the corresponding traffic identification based on the second operation request comprises:
and analyzing the annotation of the second operation request to analyze the flow identification from the annotation of the second operation request.
7. A method of traffic staining of a database according to any of claims 1 to 3 wherein the method further comprises:
Acquiring the predefined traffic protocol in the data transmission service;
and after determining the corresponding flow identification, carrying out classification processing according to the predefined flow protocol and the flow identification.
8. The method for traffic staining of the database according to claim 7 wherein the classifying according to the predefined traffic protocol and the traffic identification comprises:
and according to the predefined flow protocol and the environment source information in the flow identifier, returning the change event route in the target database to the original environment so as to realize environment isolation.
9. The method for traffic staining of the database according to claim 7 wherein the classifying according to the predefined traffic protocol and the traffic identification comprises:
and shielding the change event in the target database according to the predefined flow protocol and shielding modification information in the flow identifier so as to realize shielding specific modification.
10. A flow staining apparatus for a database, comprising: the system comprises a state confirmation module, a determination module, a generation module and a processing module;
The state confirmation module is used for confirming that the target database is in a change release state and a log opening state; and confirming that the data transmission service is in a changed subscription state to the target database;
the determining module is used for determining a flow identifier corresponding to the initiated first operation request based on a predefined flow protocol;
the generating module is used for generating a second operation request according to the flow identification and the first operation request and transmitting the second operation request to the target database;
the processing module is used for acquiring a second operation request in the change event from a log of the target database after the data transmission service subscribes to the change generated by the target database based on the second operation request; and determining the corresponding flow identification based on the second operation request.
11. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to run the computer program to perform the steps of the flow staining method of the database of any of claims 1 to 9.
12. A computer readable storage medium having stored thereon a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the flow staining method of the database of any of claims 1 to 9.
CN202210303122.2A 2022-03-25 2022-03-25 Flow dyeing method and device for database, electronic device and storage medium Pending CN116841970A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210303122.2A CN116841970A (en) 2022-03-25 2022-03-25 Flow dyeing method and device for database, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210303122.2A CN116841970A (en) 2022-03-25 2022-03-25 Flow dyeing method and device for database, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN116841970A true CN116841970A (en) 2023-10-03

Family

ID=88158607

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210303122.2A Pending CN116841970A (en) 2022-03-25 2022-03-25 Flow dyeing method and device for database, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN116841970A (en)

Similar Documents

Publication Publication Date Title
US11477084B2 (en) Method and system for node discovery and self-healing of blockchain networks
CN112860451A (en) Multi-tenant data processing method and device based on SaaS
WO2020248375A1 (en) Method and system for synchronizing data between databases, computer device and storage medium
CN110909521A (en) Synchronous processing method and device for online document information and electronic equipment
CN109408594B (en) Cross-chain data retrieval system based on block chain
CN113704790A (en) Abnormal log information summarizing method and computer equipment
US9185148B1 (en) Methods and systems for efficient discovery of devices in a peer-to-peer network
CN110958180B (en) Gateway routing method, intelligent gateway, electronic device and computer storage medium
CN110457132B (en) Method and device for creating functional object and terminal equipment
US7797273B2 (en) System and a method for reliable symmetric data synchronization
CN109981546B (en) Method and device for acquiring remote call relation between application modules
CN114064712A (en) Data access method and device, electronic equipment and computer readable storage medium
CN111813685B (en) Automatic test method and device
CN112131014B (en) Decision engine system and business processing method thereof
US11870746B2 (en) Method for chatting messages by topic based on subscription channel reference in server and user device
CN116841970A (en) Flow dyeing method and device for database, electronic device and storage medium
EP4369203A1 (en) Cloud platform docking debugging method and apparatus, and electronic device and storage medium
CN114201484A (en) Information processing method, information processing device, electronic equipment and storage medium
CN112269941A (en) Business real-time pushing method and system, electronic equipment and storage medium
CN115982285B (en) Data processing method, apparatus and computer readable storage medium
CN110362706B (en) Data searching method and device, storage medium and electronic device
US20230198924A1 (en) Message capture in a multi channel communication environment
CN118283108A (en) Service processing method, system, device, medium and program product
CN115242606A (en) Data processing method, data processing apparatus, server, storage medium, and program product
CN118093218A (en) Device driver management method, device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication